import heapq from sys import exit class HeapDict: def __init__(self): self.h=[] self.d=dict() def insert(self,x): heapq.heappush(self.h,x) if x not in self.d: self.d[x]=1 else: self.d[x]+=1 def erase(self,x): if x not in self.d or self.d[x]==0: print(x,"is not in HeapDict") exit() else: self.d[x]-=1 while len(self.h)!=0: if self.d[self.h[0]]==0: heapq.heappop(self.h) else: break def is_exist(self,x): if x in self.d and self.d[x]!=0: return True else: return False def get_min(self): return self.h[0] n = int(input()) a = list(map(int,input().split())) d = {} hq = HeapDict() for i,x in enumerate(a): d[x] = i hq.insert(x) ans = 0 k = 0 while k < n: m = hq.get_min() k += 1 ans += 1 hq.erase(m) if 0 <= d[m]-1 and hq.is_exist(a[d[m]-1]): hq.erase(a[d[m]-1]) k += 1 print(ans)