#include <bits/stdc++.h>
using namespace std;
// why am I so weak
int n;
int a[2555];
int dp[2555];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
}
sort(a + 1, a + n + 1);
memset(dp, 63, sizeof(dp));
dp[0] = 0;
dp[1] = 1;
for (int i = 2; i <= n; i++) {
if (abs(a[i] - a[i - 1]) <= 2) {
dp[i] = min(dp[i], dp[i - 2] + 1);
}
dp[i] = min(dp[i], dp[i - 1] + 1);
}
printf("%d\n", dp[n]);
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgovLyB3aHkgYW0gSSBzbyB3ZWFrCgppbnQgbjsKaW50IGFbMjU1NV07CmludCBkcFsyNTU1XTsKCmludCBtYWluKCkgewoJc2NhbmYoIiVkIiwgJm4pOwoKCWZvciAoaW50IGkgPSAxOyBpIDw9IG47IGkrKykgewoJCXNjYW5mKCIlZCIsICZhW2ldKTsJCgl9CgoJc29ydChhICsgMSwgYSArIG4gKyAxKTsKCgltZW1zZXQoZHAsIDYzLCBzaXplb2YoZHApKTsKCglkcFswXSA9IDA7CglkcFsxXSA9IDE7CgoJZm9yIChpbnQgaSA9IDI7IGkgPD0gbjsgaSsrKSB7CgkJaWYgKGFicyhhW2ldIC0gYVtpIC0gMV0pIDw9IDIpIHsKCQkJZHBbaV0gPSBtaW4oZHBbaV0sIGRwW2kgLSAyXSArIDEpOwoJCX0KCgkJZHBbaV0gPSBtaW4oZHBbaV0sIGRwW2kgLSAxXSArIDEpOwoJfQoKCXByaW50ZigiJWRcbiIsIGRwW25dKTsKCglyZXR1cm4gMDsKfQ==