Cows in Bed
InterviewTime limit1sMemory limit1024 MB
Find the smallest K such that the N brand numbers all have distinct remainders when divided by K.
- Level
Easy3 of 10
- Topics
- Brute force, Hash map
- Solved
- No attempts yet
Problem
FJ has cows () who sleep in a barn with stalls numbered to . The -th cow has a unique brand number (). Cow sleeps in stall . Cows never share a stall.
Given the cows and their brands, find the minimum such that no two cows sleep in the same stall.
Input
The first line contains one integer . Each of the next lines contains one cow's brand number.
Output
Print a single line containing the minimum value of .