12931 - Finding pairs   

Description

Given an integer sequence, you are asked to compute how many pairs are there in the sequence.

Pair definition: if sequence[a] =  sequence[b] and a < b, then sequence[a] and sequence[b] are pairs. (a , b are index)

For example:

Input sequence = 1 2 4 1 9 7 2 3 1 8

There are 4 pairs which index pairs are (0, 3), (0, 8), (1, 6), (3, 8) in this sequence .

 

Input

First line contains an integer N which denotes the length of the input sequence. ( 100000)

Second line contains N integer which denote the input sequence. ( each number in input sequence  10000)

Output

An integer which denote the number of pairs in the sequence.

Remember to print a newline('\n') at the end of the last line.

Sample Input  Download

Sample Output  Download

Tags




Discuss