2204. Addon

单点时限: 2.0 sec

内存限制: 256 MB

Scientists discovered a new radioactive element - addon. It appeared that addon was the most efficient nuclear fuel ever known so it was decided that an addon reactor should be constructed.

According to the project a fuel chamber is a vertical pipe. Fuel rods, i.e. addon cylinders, are placed in a chamber one above another. Fuel rods have various lengths.

The cycle of the reactor begins with putting fuel rods into the chamber. The next step is the ignition. Unfortunately, the height of a column of fuel cannot be arbitrary - only certain heights ensure safety of the reaction. Such heights are called stable heights.

Designers of a reactor have two tasks: to establish the height of the fuel chamber and to chose the set of lengths, in which addon rods will be produced.

We say that a set of lengths is safe (for a given chamber) if for any column, which is constructed from rods whose lengths belong to this set and which is not higher than the height of the chamber, the height of this column is stable.

We say that a set of lengths is complete (for a given chamber) if every column of stable height, not higher than the height of the chamber, can be constructed of rods, whose lengths are taken from this set.

Write a program that:

  • reads the set of stable heights,

  • computes the maximal height of a chamber for which a safe and complete set of lengths exists,

  • finds for such a chamber a safe and complete set of lengths with minimal possible number of elements,

  • writes the result.

输入格式

In the first line there is a natural number n, 1 <= n <= 10000, which is the number of given stable heights.

In each of the following n lines there is one positive integer, not greater than 10000. These numbers represent stable heights and are given in increasing order.

输出格式

In the first line there should be written one integer - the maximal height of a chamber.

In the following lines there should be written (in increasing order) computed set of lengths (one number in one line).

样例

Input
14
5
10
12
15
17
20
21
22
24
26
27
30
31
33
Output
24
5
12
21

2 人解决,3 人已尝试。

3 份提交通过,共有 8 份提交。

8.7 EMB 奖励。

创建: 16 年,4 月前.

修改: 7 年,2 月前.

最后提交: 3 年,12 月前.

来源: POI 1997 II Stage

题目标签