https://www.acmicpc.net/problem/1253

n = int(input())
nlist = sorted(list(map(int, input().split())))
def two_pointers(start, end, target, exclude_index):
while start < end:
if start == exclude_index:
start += 1
continue
if end == exclude_index:
end -= 1
continue
interval_sum = nlist[start] + nlist[end]
if interval_sum == target:
return True
elif interval_sum < target:
start += 1
else:
end -= 1
return False
count = 0
for i in range(len(nlist)):
# nlist에서 i번째 요소를 제외한 부분을 탐색해야 한다.
if two_pointers(0, n-1, nlist[i], i):
count += 1
print(count)