Ali invents a jumping robot. This robot is controlled by a program {Di}, which is a finite sequence of non-negative “jumping distances”. The program can’t be changed once the robot is made.
There are L boxes in a line. Each time the robot is placed in one of the boxes, facing left or right, and then it is turned on. It first jumps over D1 boxes, then jumps over D2 boxes ...
Ali writes a capital letter in each box. The robot prints out all the letter it touches, including the initial one. Now he wants to design a program with a length of p, so that for every kind of letters in the boxes, if you carefully choose the initial position and direction of the robot, it can print out a sequence of that letter of length p.
What’s the maximum possible p for the given letters in boxes?