n=gets.to_i
a=[]
n.times do|i|
	a[i]=gets.to_i
end
cnt=0
while true
	i=0
	max=a[0]
	tmp=max
	a.delete_at(0)
	s=a.size
	while(i<s)
		if(a[i]>max)
			max=a[i]
			a.delete_at(i)
			s-=1
		else
			i+=1
		end
	end
	cnt+=1
	if(a.size==0)
		break
	elsif(tmp==max)
		cnt+=s
		break
	end
end
p cnt