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