Find the maximum element in the array other than a [ i ]
for ( int i = 0 ; i < n ; i ++ ) { if ( i == 0 ) cout << suf [ i + 1 ] << " ▁ " ; else if ( i == n - 1 ) cout << pre [ i - 1 ] << " ▁ " ; else cout << max ( pre [ i - 1 ] , suf [ i + 1 ] ) << " ▁ " ; } }