Find the maximum in prefix array
for i in range ( n - 1 ) : NEW_LINE INDENT if ( a [ i ] > max ) : NEW_LINE INDENT max = a [ i ] NEW_LINE DEDENT pre [ i ] = max NEW_LINE DEDENT max = a [ n - 1 ] NEW_LINE suf [ n - 2 ] = a [ n - 1 ] NEW_LINE