#P2141. 珠心算加法测试

    ID: 15422 Type: Default 1000ms 256MiB

珠心算加法测试

珠心算加法测试

This problem is about an abacus mental calculation technique called "珠心算". In this test, you are given a set of distinct positive integers. Your task is to count how many numbers in the set can be expressed exactly as the sum of two other different numbers from the set.

Formally, given a set \(S = \{a_1, a_2, \dots, a_n\}\) of distinct positive integers, find the number of elements \(x \in S\) for which there exist two distinct elements \(y, z \in S\) (with \(y \neq z\)) such that \(x = y + z\). Note that each number is considered at most once even if there are multiple representations.

inputFormat

The first line contains a positive integer \(n\) (where \(n \ge 3\)), the number of integers in the set. The second line contains \(n\) distinct positive integers separated by spaces.

outputFormat

Output a single integer representing the count of numbers in the set that can be represented as the sum of two other distinct numbers from the set.

sample

5
1 2 3 5 7
3