#include //#include using namespace std; //using namespace atcoder; using ll = long long; using ull = unsigned long long; using P = pair; #define rep(i,n) for(ll i = 0;i < (ll)n;i++) #define ALL(x) (x).begin(),(x).end() #define MOD 1000000007 vector dp(200100,-1); ll dfs(vector &v,int pos){ if(pos >= v.size())return 0; ll res = 0; for(int i = 1;i <= 2;i++){ if(pos+i >= v.size())break; if(v[pos+i]-v[pos] == 2)res += dfs(v,pos+i); } return dp[pos] = res+1; } int main(){ int n; cin >> n; vector v(n); rep(i,n)cin >> v[i]; sort(ALL(v)); vector l(n); rep(i,n)dfs(v,i); ll res = n; for(int i = 1;i < n;i++)if(v[i]-v[i-1] == 1)res += dp[i]; cout << res << "\n"; return 0; }