P13796 [SWERC 2023] Nicest view

Description

:::align{center} ![](https://espresso.codeforces.com/93613cfd23ca0223b6f9aa573bf5381a7646cd95.png) ::: Paris is so crowded with tourists during the Olympic games! You want to escape the city and go on a hike on a linear trail path, going from left to right. Every kilometre on that trail, including at start and end, is a milestone, on which is written the stone's altitude. The slope between two consecutive stones is constant, and no two stones have the same altitude. Planning to come back with your friends, you try to identify the point of the hike at which you had the nicest view. The beauty of a point of view is defined as the distance (measured in kilometres) between your position and the leftmost position that you can see on your hike and that is at the same altitude as you are. If such a previous position fails to exist, it means that you can see the city and its smog, and the beauty of that view is zero. You have listed the altitudes of the milestones. What is the maximal beauty on your hike?

Input Format

The input consists of two lines. The first line contains a single integer $N$, which is the number of milestones on the trail path. The second line contains $N$ space-separated integers $H_1, H_2, \dots, H_N$; each integer $H_k$ is the altitude (measured in metres) of the $k^\text{th}$ milestone on the path. **Limits** - $1 \leq N \leq 100~000$; - $0 \leq H_k \leq 1~000~000$ for all $k \leq N$; - the integers $H_k$ are pairwise distinct.

Output Format

The output should contain a single line, consisting of a single number $S$: the best beauty score on your hike. This number is written either as an integer or as an irreducible fraction $N/D$ for which $D \geq 2$; we recall that a fraction $N/D$ is irreducible when the greatest common divisor of $N$ and $D$ is $1$.