Whenever you want to maximize or minimize something in an array, by taking the values of a range from the elements of the same array, then you can do a binary search by taking the minimum and maximum of the elements of that array. Problem Link:- https://codeforces.net/contest/1623/problem/C