
https://www.acmicpc.net/problem/1253
import sys, bisect
def solution():
    read = sys.stdin.readline
    n = int(read())
    numbers = list(map(int, read().split()))
    numbers.sort()
    count = 0
    for i in range(n):
        if possible(n, numbers, numbers[i], i):
            count += 1
    print(count)
def possible(n, numbers, cn, ci):
    for i in range(n):
        if i == ci:
            continue
        goal = cn - numbers[i]
        j = bisect.bisect_left(numbers, goal)
        while j == i or j == ci:
            j += 1
        if not (0 <= j < n):
            continue
        if goal == numbers[j]:
            return True
solution()