A sequence of positive integers a_{1},a_{2},...,a_{n} is called
"additive chain" of length n if for every k, 1 < k <= n, there exists
indices i and j (1 <=i <=j <= n), so that a_{k}=a_{i}+a_{j}.
Write a program that, for a_{1}=1 and the last element read from input, finds out
an additive chain with minimal length.
Example The sequence 1,2,4 is an additive chain of length 3. |