There will be several test cases in the input. Each test case begins with an integer n, (1≤n≤100,000) on its own line, indicating the total number of balls begin juggled. Each of the next n lines consists of a single integer, ki (1≤ki≤n), which describes a single ball: i is the position of the ball starting clockwise from the juggler’s hand, and ki is the order in which the ball should be dropped. The set of numbers {k1, k2, …, kn} is guaranteed to be a permutation of the numbers 1..n. The input will terminate with a line containing a single 0.