Small sums P23069


Statement
 

pdf   zip

thehtml

A certain value v 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 v. You can suppose that there are, at least, three numbers.

For instance, if v 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 v, followed by a line with a number n between 3 and 10000, followed by a line with n 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 v.

Public test cases
  • Input

    15
    5
    12 2 5 14 1
    

    Output

    4
    
  • Input

    6
    3
    1 2 3
    

    Output

    3
    
  • Input

    -20
    6
    25 15 5 -5 -15 -25
    

    Output

    5
    
  • Input

    100
    3
    33 34 35
    

    Output

    0
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Spanish
    Other languages
    Spanish
    Official solutions
    C++
    User solutions
    C++