#include using namespace std; using ll = long long; ll calc(const vector &a) { int n = a.size(); int maxA = a.back(); vector dp(maxA + 2, 0); vector exist(maxA + 2, 0); for (int i = 0; i < n; i++) exist[a[i]] = true; for (int i = 0; i < maxA + 2; i++) { dp[i] += exist[i]; if (i >= 2 and exist[i - 1]) dp[i] += dp[i - 2]; } ll sum = 0; for (int i = 0; i < maxA + 2; i++) sum += dp[i]; return sum; } int main() { int n; assert(cin >> n); assert(1 <= n and n <= 200000); vector a(n); set st; for (int i = 0; i < n; i++) { assert(cin >> a[i]); st.insert(a[i]); assert(1 <= a[i] and a[i] <= 1e18); a[i]--; } assert(st.size() == n); sort(begin(a), end(a)); a.push_back(2e18); ll ans = 0, minus = a[0]; vector v; for (int i = 0; i < n; i++) { v.push_back(a[i] - minus); if (a[i + 1] - a[i] >= 3) { ans += calc(v); v.clear(); minus = a[i + 1]; } } cout << ans << "\n"; return 0; }