calculate cumulative sum of array cArray [ 0 ] will store sum of zero elements
long long int cArray [ n + 1 ] = { 0 } ; for ( i = 0 ; i < n ; i ++ ) cArray [ i + 1 ] = cArray [ i ] + arr [ i ] ; vector < long long int > subArrSum ;