Pregunta de entrevista de Amazon

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