Updates such that getElement ( ) gets an increased value when queried from l to r .
static void update ( int arr [ ] , int l , int r , int val ) { arr [ l ] += val ; if ( r + 1 < arr . length ) arr [ r + 1 ] -= val ; }