#P1881. 绳子对折

绳子对折

Description

FJ has a rope of length LL (1L10,0001 \le L \le 10,000). There are NN (1N1001 \le N \le 100) knots on the rope, including the two endpoints. FJ wants to fold the rope so that the knots on the shorter side coincide exactly with the knots on the longer side, as shown in the figure:

Find how many valid folding positions FJ can choose.

Input Format

The first line: two integers, NN and LL.

Lines 22 to N+1N+1: each line contains one integer giving the position of a knot. Among them, 00 and LL are always included.

Output Format

The first line: one integer, the number of valid folding positions.

5 10
0 
10 
6 
2 
4

4

Hint

(You can fold at positions 1, 2, 3, and 8.)

Translated by ChatGPT 5