Farmer John's $N$ cows ($1 \le N \le 50000$) are standing in a line, each described by an integer breed id.
Cows of the same breed are at risk of getting into an argument with each other if they are standing too close. Specifically, two cows of the same breed are said to be "crowded" if their positions within the line differ by no more than $K$ ($1 \le K < N$).
Compute the maximum breed id over all pairs of crowded cows.
There are 6 cows in a line with breed ids $7, 3, 4, 2, 3, 4$ and $K = 3$. Two cows of the same breed are crowded if their positions differ by at most $3$. The two cows of breed id $3$ (positions $2$ and $5$, difference $3$) are crowded, and so are the two cows of breed id $4$ (positions $3$ and $6$, difference $3$). Hence the answer is $4$.