solveImpl :: [Int] -> Int -> Int
solveImpl arr number
    | arr == []           = number
    | tmpNumber == number = solveImpl (tail arr) (number+1)
    | otherwise           = solveImpl (tail arr) number
    where tmpNumber = head arr

solve :: [Int] -> Int
solve arr
    | ans == 1  = -1
    | otherwise = length arr - ans + 1
    where ans = solveImpl arr 1

main = do
    n <- getLine
    arr <- map read . words <$> getLine
    let ans = solve arr
    print ans
