n<=105
#include<bits/stdc++.h>
using namespace std;
int main() {
stack<int> s;
int n,m;
cin>>n;
for(int i=1,j=1;i<=n;i++)
{
cin>>m;
while(j<=m)
s.push(j++);
if(m==s.top())
s.pop();
}
if(s.empty())
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
return 0;
}