|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|2 초||512 MB||66||26||22||44.898%|
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.
3 1 2 1
5 1 2 1 10 3