#P12132. Decomposable Integers Counting

    ID: 14231 Type: Default 1000ms 256MiB

Decomposable Integers Counting

Decomposable Integers Counting

We define a special integer sequence as a sequence of consecutive increasing integers, where the difference between adjacent elements is 1. The sequence must have at least (3) elements and may include negative numbers or zero. For example, ([1,2,3]), ([4,5,6,7]), and ([-1,0,1]) are valid sequences, whereas ([1,2]) (length too short) and ([1,2,4]) (non-consecutive) are not valid.

Given a list of (N) positive integers (A_1, A_2, \dots, A_N), a number (A_i) is called decomposable if it can be expressed as the sum of all elements of some valid consecutive integer sequence. In other words, there exists an integer (a) and an integer (L \ge 3) such that [ A_i = \frac{L(2a+L-1)}{2} ] where the sequence is ([a, a+1, \dots, a+L-1]).

Your task is to count how many numbers in the input list are decomposable.

inputFormat

The first line contains a single integer (N), the number of integers. The second line contains (N) space-separated positive integers (A_1, A_2, \dots, A_N).

outputFormat

Output a single integer representing the number of decomposable integers in the given list.

sample

4
6 15 9 8
3