시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB133544947.573%

문제

Fred likes to wear mismatched socks. This sometimes means he has to plan ahead. Suppose his sock drawer has one red, one blue, and two green socks. If he wears the red with the blue, he's stuck with matching green socks. He put together two mismatched pairs if he pairs red with green and then blue with green. Given the contents of his sock drawer, how many pairs of mismatched socks can he put together?

입력

Each input will consist of a single test case. Note that your program may be run multiple times on different inputs. The first line of input contains an integer n (1 ≤ n ≤ 1,000) which is the number of colors of socks in Fred's drawer. Each of the next n lines has an integer k (1 ≤ k ≤ 109 ) which is the number of socks of that color.

출력

Output a single integer indicating the number of pairs of mismatched socks that Fred can make with the contents of his sock drawer.

예제 입력 1

3
1
2
1

예제 출력 1

2

예제 입력 2

5
1
2
1
10
3

예제 출력 2

7