My solution gets a wrong answer verdict, but I can't think of a counterexample.
Here's my solution — https://codeforces.net/contest/1772/submission/190133399. I have used 0-indexing, and have set the extra last element of the input to +inf in order to avoid bounds checking.
Can anyone give me a counterexample?