시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 185 65 49 33.108%

문제

상근이는 데이터베이스 수업 시간에 교수님 몰래 교실을 나갔다. 결국 교수님에게 불려가게 되었고, 교수님은 다음과 같은 수학 숙제를 내주었다.

정수 N개가 주어진다. 이때, 친구의 개수를 구하라.

상근이는 이 문제를 받고 친구가 무엇인지 궁금해졌다. 데이터베이스 조교 동규는 두 수를 이루는 숫자가 적어도 하나 겹치는 쌍을 친구라고 한다고 했다. (겹치는 위치는 달라도 된다)

상근이의 숙제를 하는 프로그램을 작성하시오.

입력

첫째 줄에 수의 개수 N이 주어진다. (1 ≤ N ≤ 1,000,000)

다음 N개 줄에는 [1, 1018] 범위 안에 있는 양의 정수가 주어진다. 이 수가 교수님이 상근이에게 숙제로 전달한 수이다. 같은 수가 두 번 이상 주어지지 않는다.

출력

첫째 줄에 친구의 개수를 출력한다.

예제 입력 1

4
32
51
123
282

예제 출력 1

4
W3sicHJvYmxlbV9pZCI6IjI4MjUiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWMyMThcdWM1YzVcdWMyZGNcdWFjMDRcdWM1ZDAgXHVhZDUwXHVjMjE4XHViMmQ4IFx1YmFiMFx1Yjc5OCBcdWFkNTBcdWMyZTRcdWM3NDQgXHViMDk4XHVhYzA0IFx1YzBjMVx1YWRmY1x1Yzc3NCIsImRlc2NyaXB0aW9uIjoiPHA+XHVjMGMxXHVhZGZjXHVjNzc0XHViMjk0IFx1YjM3MFx1Yzc3NFx1ZDEzMFx1YmNhMFx1Yzc3NFx1YzJhNCBcdWMyMThcdWM1YzUgXHVjMmRjXHVhYzA0XHVjNWQwIFx1YWQ1MFx1YzIxOFx1YjJkOCBcdWJhYjBcdWI3OTggXHVhZDUwXHVjMmU0XHVjNzQ0IFx1YjA5OFx1YWMxNFx1YjJlNC4gXHVhY2IwXHVhZDZkIFx1YWQ1MFx1YzIxOFx1YjJkOFx1YzVkMFx1YWM4YyBcdWJkODhc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