P1881 Folding the Rope

Description

FJ has a rope of length $L$ ($1 \le L \le 10,000$). There are $N$ ($1 \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: ![](https://cdn.luogu.com.cn/upload/image_hosting/1spqhchu.png) Find how many valid folding positions FJ can choose.

Input Format

The first line: two integers, $N$ and $L$. Lines $2$ to $N+1$: each line contains one integer giving the position of a knot. Among them, $0$ and $L$ are always included.

Output Format

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

Explanation/Hint

(You can fold at positions 1, 2, 3, and 8.) Translated by ChatGPT 5