#include using namespace std; template bool cmin(T &a, U b) { return a > b && (a = b, true); } template bool cmax(T &a, U b) { return a < b && (a = b, true); } class UnionFind { private: int N; vector PS; public: UnionFind() : N(0) {} UnionFind(int n) : N(n), PS(n, -1) {} bool unite(int a, int b) { int x = root(a), y = root(b); if (x == y) return false; if (-PS.at(x) < -PS.at(y)) swap(x, y); PS.at(x) += PS.at(y); PS.at(y) = x; return true; } bool same(int a, int b) { return root(a) == root(b); } int root(int a) { if (PS.at(a) < 0) return a; return PS.at(a) = root(PS.at(a)); } int size(int a) { return -PS.at(root(a)); } vector> groups() { vector B(N), S(N); for (int i = 0; i < N; i++) { B.at(i) = root(i); S.at(B.at(i))++; } vector> ret(N); for (int i = 0; i < N; i++) { ret.at(i).reserve(S.at(i)); } for (int i = 0; i < N; i++) { ret.at(B.at(i)).push_back(i); } auto f = [&](const vector &v) { return v.empty(); }; ret.erase(remove_if(ret.begin(), ret.end(), f), ret.end()); return ret; } }; signed main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int N; cin >> N; vector A(N); for (int i = 0; i < N; i++) cin >> A.at(i); sort(A.begin(), A.end()); UnionFind UF(N); for (int i = 0; i + 1 < N; i++) { if (A.at(i) + 1 < A.at(i + 1)) UF.unite(i, i + 1); } cout << UF.groups().size() << "\n"; }