Amazon interview question

Write the a function that counts all pairs in an array.