OIG XV - zes

// https://szkopul.edu.pl/problemset/problem/WsCEgGZvejeElRDr0xT7Nwwf/site/?key=statement
// OIG XV (2 etap)

#include <algorithm>
#include <iostream>
#include <vector>

int main() {
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);

    int n;
    std::cin >> n;

    std::vector<int> v(n);

    for (int i = 0; i < n; i++) {
        std::cin >> v[i];
    }

    std::sort(v.begin(), v.end());

    int i = 0, ans = 0;

    while (i < n - 2) {
        if (abs(v[i] - v[i + 2]) <= 1) {
            ans++;
            i += 3;
        } else {
            i++;
        }
    }

    std::cout << ans << '\n';

    return 0;
}