#include using namespace std; using ll = long long; constexpr char newl = '\n'; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); ll ans = n; for (int i = 1; i < n; i++) { if (a[i] - a[i - 1] != 1) continue; ll cur = a[i]; ++ans; for (int j = i + 1; j < n; j++) { if (a[j] > cur + 2) break; if (a[j] < cur + 2) continue; cur += 2; ++ans; } } cout << ans << newl; return 0; }