Rise, sequence, rise We have a strictly increasing sequence of non-negative integers, like:

12 11 10


Wait! This sequence isn't strictly increasing, is it? Well, the numbers are written in different bases. The least possible base is 2, the biggest is 10.

The task is to guess bases each number is written, so that:


the sequence is strictly increasing,
the sum of the bases is maximised.


For instance, the solution for the sample will be:

6 8 10


because under those bases the sequence becomes 8 9 10 decimal - a strictly increasing sequence, and we are not capable of finding bases for which the sequence remains strictly increasing and whose sum is bigger than 6+8+10 .

Due to the second limitation a solution 3 5 7 is not satisfactory: in spite of fact that the sequence becomes 5 6 7 under those bases - we need to maximise the bases sum, and 3+5+7 &lt; 6+8+10.

If under no bases 2&lt;=b&lt;=10 is it possible for the series to be strictly increasing, for instance:

102 10000 10


single

0


should be output.

The input sequence can be passed in the way it's most convenient for your solution (standard input / command line parameters / function arguments...).
Pyth, 31 30 29 bytes

e+0f.x!sgM.:iVczdT2ZosN^STlcz


1 byte thanks to @Jakube.

Demonstration. Test Harness.

Input is given on STDIN, space separated. If newline separated input is allowed, I can shorten the program by 2 bytes.

Explanation:

e+0f.x!sgM.:iVczdT2ZosN^STlcz
                                  Implicit: z = input(), T = 10, Z = 0, d = ' '
                        ST        [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
                          lcz     len(z.split())
                       ^          All combinations w/replacement of that length.
                    osN           Order by increasing sum.
   f                              Filter on
              czd                 z.split(' ')
            iV   T                Vectorize the "Convert to base" operation over 
                                  the integers as strings and the base sequence.
          .:      2               Take length 2 subsequences.
        gM                        Map the &gt;= operation over them.
      !s                          Sum and logically negate.
    .x             Z              If that throws an error, returns 0 (e.g. reject)
 +0                               Prepend a 0, in case no sequences are found.
e                                 Take the end of the list.


Including 1 in the list of possible bases is safe because i, which uses Python's int builtin, doesn't allow 1 as a base, and therefore always throws an error, which is caught and filtered out.