Driven Program
public static void main ( String [ ] args ) { int q = 3 ; int L [ ] = { 2 , 2 , 24 } ; int R [ ] = { 5 , 2 , 28 } ; int prefix [ ] = new int [ MAX ] , suffix [ ] = new int [ MAX ] ; precompute ( prefix , suffix ) ; for ( int i = 0 ; i < q ; i ++ ) { System . out . println ( query ( prefix , suffix , L [ i ] , R [ i ] ) ) ; } } }