Calculate the sum till the last index in crr [ ] which is less than N which contains a positive element
for ( int i = 0 ; i < N ; i ++ ) { if ( crr [ i ] > 0 ) { sum += crr [ i ] ; } else { break ; } }