As a part of a new advertising campaign, a big company in Gdynia wants to put its logo somewhere in the city. The company is going to spend the whole advertising budget for this year on the logo, so it has to be really huge. One of the managers decided to use whole buildings as parts of the logo.
The logo consists of n vertical stripes of different heights. The stripes are numbered from 1 to n from left to right. The logo is described by a permutation (s1, s2, . . . , sn) of numbers 1, 2, . . . , n. The stripe number s1 is the shortest one, the stripe number s2 is the second shortest etc., finally the stripe sn is the tallest one. The actual heights of the stripes do not really matter.
There are m buildings along the main street in Gdynia. To your surprise, the heights of the buildings are distinct. The problem is to find all positions where the logo matches the buildings.
Help the company and find all contiguous parts of the sequence of buildings which match the logo. A contiguous sequence of buildings matches the logo if the building number s1 within this sequence is the shortest one, the building number s2 is the second shortest, etc. For example a sequence of buildings of heights 5, 10, 4 matches a logo described by a permutation (3, 1, 2), since the building number 3 (of height 4) is the shortest one, the building number 1 is the second shortest and the building number 2 is the tallest.
입력 5 10 2 1 5 3 4 5 6 3 8 12 7 1 10 11 9 출력 2 2 6
Explanation: Both the sequences 6, 3, 8, 12, 7 and 7, 1, 10, 11, 9 match the logo described by the permutation (2, 1, 5, 3, 4). In particular, in the first sequence the building number 2 (of height 3) is the shortest one, the building number 1 (of height 6) is the second shortest, the building number 5 (of height 7) is the third shortest, and so on.
출처:ceoi 2011