Pergunta de entrevista da empresa Amazon

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