#P1367. [Baltic2004]sequence

[Baltic2004]sequence

Description

Input

Output

一个整数R

Samples

7
9
4
8
20
14
15
18
13

Limitation

所求的Z序列为6,7,8,13,14,15,18. R=13