Balance beam (2)

A gymnast is at the midpoint of a balance beam of length mm. The gymnast must jump nn times forward or backward, never leaving the bar. The ii-th jump has length i\ell_i. Write a program to computes in how many ways the gymnast can finish the exercise at every position. The gymnast cannot skip any jump, nor change the order of the jumps.

Input

Input consist of the length mm, the number nn, and the lengths 1,,n\ell_1, \dots, \ell_n. Assume 2m1032 \le m \le 10^3, that mm is even, 0n1040 \le n \le 10^4, and 1i1001 \le \ell_i \le 100.

Output

Assuming that the initial position is 0 (hence, the valid positions belong to [m/2,m/2][-m/2, m/2]), print in order the positions where the gymnast can finish, together with the number of ways modulo 108+710^8 + 7.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T11:18:06.871Z

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