QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 64 MB Total points: 100

#582. Pilots

الإحصائيات

In the Byteotian Training Centre, the pilots prepare for missions requiring extraordinary precision and control. One measure of a pilot's capability is the duration he is able to fly along a desired route without deviating too much - simply put, whether he can fly steadily. This is not an easy task, as the simulator is so sensitive that it registers even a slightest move of the yoke ^[1]. At each moment the simulator stores a single parameter describing the yoke's position. Before each training session a certain tolerance level $t$ is set. The pilots' task then is to fly as long as they can in such a way that all the yoke's position measured during the flight differ by at most $t$. In other words, a fragment of the flight starting at time $i$ and ending at time $j$ is within tolerance level t if the position measurements, starting with i-th and ending with $j$-th, form such a sequence $a_i,…,a_j$ that for all elements $a_k,a_l$ of this sequence, the inequality $|a_k-a_l| ≤ t$ holds.

Your task is to write a program that, given a number and the sequence of yoke's position measurements, determines the length of the longest fragment of the flight that is within the tolerance level $t$.

^[1]: a device used for piloting in an aircraft

Input

In the first line of the standard input two integers are given, $t$ and $n$ ($0 ≤ t ≤ 2\,000\,000\,000$, $1 ≤ n ≤ 3\,000\,000$), separated by a single space, denoting the tolerance level and the number of yoke's position measurements taken. The second line gives those measurements, separated by single spaces. Each measurement is an integer from the interval from $1$ to $2\,000\,000\,000$.

Output

Your program should print a single integer to the standard output: the maximum length of a fragment of the flight that is within the given tolerance level.

Example

Input

3 9
5 1 3 5 8 6 6 9 10

Output

4
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.