시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 192 MB134542328933.066%

문제

상근이는 초등학교 졸업 여행으로 외계 행성 X3에 방문했었다. 이 행성에 사는 사람들의 이름은 모두 자연수이다. 행성의 거주민은 모두 서로를 알고 있다. 두 X3인은 그들의 친밀도를 자신의 이름을 이진수로 바꾸어서 계산한다. 두 이름을 이진수로 바꾸고, 자리수가 짧은 쪽을 기준으로 정렬한다. 이때, 두 이진수의 각 자리 아래에 두 자리가 같으면 0을, 다르면 1을 적는다. 이 결과 이진수를 다시 10진수로 바꾸면 그들의 친밀도가 된다.

예를 들어, 10과 19의 친밀도는 25이다.

1 0 0 1 1 = 19
0 1 0 1 0 = 10
--------------
1 1 0 0 1 = 25

행성의 가치는 이 섬에 있는 모든 친밀도의 합이다. 행성 거주민들의 이름이 주어졌을 때, 행성의 가치를 구하는 프로그램을 작성하시오.

입력

첫째 줄에 X3 거주민의 수 N이 주어진다. (1 ≤ N ≤ 1,000,000) 다음 N개의 줄에는 거주민의 이름이 주어진다. 이름은 1,000,000보다 작거나 같은 자연수이다.

출력

첫째 줄에 행성 X3의 가치를 출력한다.

예제 입력 1

2
19
10

예제 출력 1

25

예제 입력 2

3
7
3
5

예제 출력 2

12

예제 입력 3

5
9
13
1
9
6

예제 출력 3

84
W3sicHJvYmxlbV9pZCI6IjI4MzAiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWQ1ODlcdWMxMzEgWDMiLCJkZXNjcmlwdGlvbiI6IjxwPlx1YzBjMVx1YWRmY1x1Yzc3NFx1YjI5NCBcdWNkMDhcdWI0ZjFcdWQ1NTlcdWFkNTAgXHVjODc4XHVjNWM1IFx1YzVlY1x1ZDU4OVx1YzczY1x1Yjg1YyBcdWM2NzhcdWFjYzQgXHVkNTg5XHVjMTMxIFgzXHVjNWQwIFx1YmMyOVx1YmIzOFx1ZDU4OFx1YzVjOFx1YjJlNC4gXHVjNzc0IFx1ZDU4OVx1YzEzMVx1YzVkMCBcdW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