I can only get O(n^2) solution for below question. Any better idea?

Given an array of integers you to find the range l (the starting

index) and r (the ending index) such that AND operation of largest two

elements in that range is maximum. For example: Input 8 4 3 1 Output 2

3 You have to print lexicographically smallest range.