Popes

On the occasion of Pope John Paul II death, the American weekly magazine Time observed the largest number of Popes to be selected in a 100-year period was 28, from 867 (Adrian II) to 965 (John XIII). This is a very interesting piece of trivia, but it would be much better to have a program to compute that number for a period of any length, not necessarily 100 years. Furthermore, the Catholic Church being an eternal institution, as far as we can predict it, we want to make sure that our program will remain valid per omnia secula seculorum. Write a program that given the list of years in which each Pope was elected and a positive number Y , computes the largest number of Popes that were in office in a Y -year period, and the year of election for the first and last Popes in that period. Note that, given a year N , the Y -year period that starts in yearN isthetimeintervalfromthefirstdayofyearN tothelastdayofyearN+Y −1. Incaseofa tie, i.e., if there is more that one Y -year period with the same largest number of Popes, your program should report only the most ancient one. Input The input will contain several test cases, each of them as described below. Consecutive test cases are separated by a single blank line. The first line of the input contains a positive integer Y , the number of years of the period we are interested in. The second line contains another positive integer, the number of Popes, P. Each of the remaining P lines contains the year of election of a Pope, in chronological order. We know that P ≤100000andalsothatthelastyearLinthefileissuchL≤1000000,andthatY ≤L. Output For each test case, write to the output contains a single line with three integers, separated by spaces: the largest number of Popes in a Y -year period, the year of election of the first Pope in that period and the year of election of the last Pope in the period. Sample Input 5 20 1 2 3 6 8 12 13 13 15 16 17 18 19 20

2/2 20 21 25 26 30 31 Sample Output 6 16 20