To store cumulative 1 's  $left[$n]; $right[$n];
if ( $ s [ 0 ] == '1' ) $ left [ 0 ] = 1 ; else $ left [ 0 ] = 0 ; if ( $ s [ $ n - 1 ] == '1' ) $ right [ $ n - 1 ] = 1 ; else $ right [ $ n - 1 ] = 0 ;