N = int(raw_input()) a = map(int,raw_input().split()) tmp = N cnt = 0 for i in xrange(N-1,-1,-1): if a[i] == tmp: cnt += 1 tmp -= 1 print N-cnt