{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"A musical melody is represented as a sequence of N (1\u0026lt;\u003dN\u0026lt;\u003d20000)notes that are integers in the range 1..88, each representing a key on the piano. It is unfortunate but true that this representation of melodies ignores the notion of musical timing; but, this programming task is about notes and not timings. \r\u003cbr\u003eMany composers structure their music around a repeating \u0026amp;qout;theme\u0026amp;qout;, which, being a subsequence of an entire melody, is a sequence of integers in our representation. A subsequence of a melody is a theme if it: \r\u003cbr\u003e\u003cul\u003e\u003cli\u003eis at least five notes long \r\u003cbr\u003e\u003c/li\u003e\u003cli\u003eappears (potentially transposed -- see below) again somewhere else in the piece of music \r\u003cbr\u003e\u003c/li\u003e\u003cli\u003eis disjoint from (i.e., non-overlapping with) at least one of its other appearance(s) \u003c/li\u003e\u003c/ul\u003e\r\u003cbr\u003eTransposed means that a constant positive or negative value is added to every note value in the theme subsequence. \r\u003cbr\u003eGiven a melody, compute the length (number of notes) of the longest theme. \r\u003cbr\u003eOne second time limit for this problem\u0027s solutions! \r\u003cbr\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The input contains several test cases. The first line of each test case contains the integer N. The following n integers represent the sequence of notes.\r\u003cbr\u003eThe last test case is followed by one zero. \r\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, the output file should contain a single line with a single integer that represents the length of the longest theme. If there are no themes, output 0. "}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e30\r\n25 27 30 34 39 45 52 60 69 79 69 60 52 45 39 34 30 26 22 18\r\n82 78 74 70 66 67 64 60 65 80\r\n0\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"Use scanf instead of cin to reduce the read time."}}]}