In the above implementation we have considered every triplet three times so we have to divide every sum3 array element by 3
for ( $ i = 1 ; $ i < $ max_Element ; $ i ++ ) $ sum3 [ $ i ] = ( int ) ( $ sum3 [ $ i ] / 3 ) ;