#include using namespace std::literals::string_literals; using i64 = std::int_fast64_t; using std::cout; using std::cerr; using std::endl; using std::cin; template std::vector make_v(size_t a){return std::vector(a);} template auto make_v(size_t a,Ts... ts){ return std::vector(ts...))>(a,make_v(ts...)); } int main() { int n; scanf("%d", &n); std::vector a(n); for(auto& v: a) scanf("%lld", &v); sort(begin(a), end(a)); std::vector> A, B; for(auto v: a) { if(v & 1) { if(A.empty() or A.back().second + 2 != v) A.push_back({v, v}); else A.back().second += 2; } else { if(B.empty() or B.back().second + 2 != v) B.push_back({v, v}); else B.back().second += 2; } } i64 ans = n; int x = 0, y = 0; for(int i = 0; i < n; i++) { if(i + 1 >= n or a[i] + 1 != a[i + 1]) continue; while(x < A.size() and A[x].second < a[i]) x++; while(y < B.size() and B[y].second < a[i]) y++; if(a[i] & 1) { ans += (B[y].second - a[i + 1]) / 2 + 1; } else { ans += (A[x].second - a[i + 1]) / 2 + 1; } } printf("%lld\n", ans); return 0; }