Check if it is present at index i - 2
elif ( ( ( i - 2 ) >= 0 ) and A [ i - 2 ] == ( i + 1 ) ) : NEW_LINE INDENT cnt += 2 NEW_LINE A [ i - 2 ] = A [ i - 1 ] NEW_LINE A [ i - 1 ] = A [ i ] NEW_LINE A [ i ] = i + 1 NEW_LINE DEDENT