#include <bits/stdc++.h>
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<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n); std::vector<i64> a(n);
	for(auto& v: a) scanf("%lld", &v);
	sort(begin(a), end(a));

	std::vector<std::pair<i64, i64>> 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;
}