Small sums

A certain value vv is given to you, as well as some different numbers. Your program must compute how many of the given numbers can be added up with other two given numbers, so that the sum is not greater than vv. You can suppose that there are, at least, three numbers.

For instance, if vv is 15 and the given numbers are 12, 2, 5, 14 and 1, there only is a number (14) that cannot be added up with other two numbers without exceeding 15. All the other numbers can be added up. For instance, 2 can be added up with 5 and 1, giving as a result 8, that is less or equal than 15.

Input

The input consists of a line with an integer vv, followed by a line with a number nn between 3 and 10000, followed by a line with nn different numbers.

Output

Your program must print a line with the quantity of the fiven numbers that can be added up with other two of these numbers so that the result is not greater than vv.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T10:17:06.495Z

© Jutge.org, 2006–2026.
https://jutge.org