Calculate distance from end
for j in range ( N - 1 , - 1 , - 1 ) : NEW_LINE INDENT sum_end += arr [ j ] NEW_LINE if ( arr [ j ] == X ) : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( min ( sum_end , sum_start ) , end = " ▁ " ) NEW_LINE