/*****************************************************************
> File Name: tmp.cpp
> Author: Uncle_Sugar
> Mail: uncle_sugar@qq.com
> Created Time: 2016年03月24日 星期四 15时41分59秒
*****************************************************************/
# include <cstdio>
# include <cstring>
# include <cmath>
# include <cstdlib>
# include <climits>
# include <iostream>
# include <iomanip>
# include <set>
# include <map>
# include <vector>
# include <stack>
# include <queue>
# include <algorithm>
using namespace std;
const int debug = 1;
const int size = 5000 + 10;
const int INF = INT_MAX>>1;
typedef long long ll;
int main()
{
std::ios::sync_with_stdio(false);cin.tie(0);
int i,j,k;
map<int,int> mp;
int n;
while (cin >> n){
mp.clear();
int tmp,ans=0;
while (n--){
cin >> tmp;
if (mp[tmp]<=0){
mp[tmp] = 1;
ans++;
}
mp[tmp]--;
mp[tmp-1]++;
}
cout << ans << '\n';
}
return 0;
}