## DMOPC '22 Contest 4 P4 - Anki Reviews

View as PDF

Points: 17 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

Edward just lost his Anki streak of 981 days! Completely panic-stricken, he scrambles for ways to recover his lost streak. Luckily, he remembered that the streak calculator works based on Anki's time zone, and that changing the time zone could have the potential to recover some of his streak. Specifically, Edward has logged reviews, the -th review at minute . In his world, each day consists of minutes. If he picks a time zone that resets at minute , then each day spans the minutes for some integer . A day is considered active if Edward did at least one review that day, and a streak is a consecutive sequence of active days. Your job is to determine the longest possible length of the longest streak, given that Edward picks an optimal value of .

#### Input Specification

The first line contains integers and .

The next line contains space-separated integers . These are given in non-decreasing order.

#### Output Specification

Output the length of the longest streak, given that Edward picks an optimal value of .

#### Sample Input

5 3
3 5 5 7 16

#### Sample Output

3

#### Explanation for Sample

Edward can pick a reset time of . Then, the th day consists of minutes , the st day consists of minutes , the nd day consists of minutes , and so on. Days , and are active, so the longest streak is days.