People go to the cinema in groups (some go alone). Every group only wants to socialize within itself, so each group insists on at least one empty seat between itself and any neighbouring group in the same row — unless the group sits at one of the two ends of the row, where no empty seat is required on that side.
The cinema is triangular. If the widest row has $X$ seats, then the rows have $X, X-1, X-2, \dots, 1$ seats (one row of each width from $X$ down to $1$). Because of a capacity limit, the widest row may have at most $12$ seats.
The visitors are described by a list $(N_1, \dots, N_n)$, where $N_i$ is the number of groups that consist of exactly $i$ people. Every group must be seated in a single row (a group is never split across rows) and the seats a group occupies must be consecutive.
Find the smallest possible width $X$ of the widest row such that all groups can be seated at the same time while respecting the one-empty-seat rule.
The first line contains a single integer $n$ ($1 \le n \le 12$): the size of the largest possible group.
The second line contains $n$ integers; the $i$-th of them (1-indexed) is $N_i$, the number of groups of exactly $i$ people that must be seated.
Print a single value: the smallest width $X$ of the widest row that seats everyone. If no width from $1$ to $12$ can seat all groups, print impossible instead.