#include using namespace std; int n; vector a; int solve(); int main() { cin >> n; a.resize(n); for (auto &p : a) cin >> p; cout << solve() << endl; return 0; } int solve() { vector v; queue qu; sort(a.begin(), a.end()); for (int i = 0; i < n; ++i) { while (qu.size() && qu.front() + 1 < a[i]) { v.push_back(qu.front()); qu.pop(); } if (v.size() && v.back() + 1 < a[i]) v.pop_back(); qu.push(a[i]); } return v.size() + qu.size(); }