Driver Code
public static void main ( String args [ ] ) { int [ ] arr = { 2 , 4 , 8 , 16 , 32 , 64 , 128 , 256 } ; int queries = 3 ; int [ ] [ ] q = { { 2 , 4 } , { 2 , 6 } , { 5 , 8 } } ; int n = arr . length ; for ( int i = 0 ; i < queries ; i ++ ) System . out . println ( findSum ( arr , n , q [ i ] [ 0 ] , q [ i ] [ 1 ] ) ) ; } }