Acka Rhythm World
Time limit2sMemory limit512 MB
Given N distinct tap times, find the maximum count of times sharing the same remainder modulo some integer k >= 2, over all k and remainders.
- Level
Medium7 of 10
- Topics
- Number theory, Math, Brute force, Implementation
- Solved
- No attempts yet
Problem
There is a new rhythm game called Acka Rhythm World. The score depends only on the times at which the screen was tapped.
After collecting tap times, for every integer with and every integer , define as the number of tap times that can be written in the form , where is an integer. In other words, counts the tap times whose remainder modulo equals the remainder of .
The score is the largest value of over all choices of and .
Given the tap times, write a program that computes the score.
Input
The first line contains the number of taps ().
The second line contains tap times in strictly increasing order, separated by spaces. All times are distinct integers from to inclusive.
Output
Print the score obtained by applying the rule to the given tap times.
Hint
Changing the integer is the same as choosing a remainder modulo . It never hurts to choose equal to one of the tap times. When is larger than every difference between tap times, distinct times fall into distinct remainders, so the score is .