n = int(input()) a = [int(i) for i in input().split()] for i in range(al.index(max(a)), -1, -1): if al[i] == n: n -= 1 print(n)