Driver code
int main ( ) { int a [ ] = { 1 , 5 , 4 , 2 , 8 , 6 , 7 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; int q [ ] [ 2 ] = { { 2 , 5 } , { 1 , 3 } , { 1 , 5 } , { 3 , 6 } } ; int m = sizeof ( q ) / sizeof ( q [ 0 ] ) ; solveQueries ( a , n , q , m ) ; return 0 ; }