eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків

Count

Given is a sequence of n integers: a1, a2 ,..., an. Given is also an integer v. We consider pairs (ai , aj ) of elements from the given sequence, such that i < j.

Write a program that finds such pair, whose sum (ai + aj) is the closest to (or the same as) the value of v and output the number of all such pairs with sums (ai + aj) that are equally closest to the value of v.

Input

On the first line of the standard input, the value of n is written. On the second line, the values of a1 , a2 , ... , an, are written, separated by space. On the third line, the value of v is written.

Output

On the standard output, your program has to print one integer, equal to the wanted count of pairs.

Constraints

  • 1 < n106 ;
  • −104ai104 (1in)
  • −104v104 .

Explanation for the first sample case

The value v = 12 cannot be obtained as a sum of elements of some considered pairs. But 13 can, e.g. 2 + 11 = 13. So, distance between v = 12 and 13 is 1. There exist some other pairs of elements, which sum is at distance 1 from v = 12. They are: 2 + 9 = 11, 2 + 9 = 11, 5 + 8 = 13. The total number of pairs with sum 11 or 13 is 4. Pay attention that the pair (2, 9) is count twice, because in the given sequence there are two different pairs of elements, although of equal value (2, 9).

Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
9
2 5 8 9 9 11 12 15 16
12

Вихідні дані #1
4
Джерело EJOI 2017 - Practice Session Day 0