prefixMin [ i ] contains minimum element till i
for i in range ( 1 , N - 1 , 1 ) : NEW_LINE INDENT prefixMin [ i ] = min ( arr [ i ] , prefixMin [ i - 1 ] ) NEW_LINE DEDENT ans = sys . maxsize NEW_LINE for i in range ( 3 , N - 1 , 1 ) : NEW_LINE INDENT ans = min ( ans , arr [ i ] + prefixMin [ i - 2 ] ) NEW_LINE DEDENT return ans NEW_LINE