#include<bits/stdc++.h>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, i, j, d = 0, brp = 0, poz = 0;
	bool ziv = true;
	cin >> n;
	vector<char> s(n);
	deque<int> a(n);
	for(i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end(), [](int x, int y){
			return abs(x) < abs(y);
	});
	i = 0;
	while(d != n && brp < 1000000 && ziv == true){
		if(poz - a[i] == -1){
			s[i].push_back(1);
			d++;
			brp++;
			a.pop_front();
			for(j = 0; j < a.size(); j++){
				if(a[j] >= 0) a[j]--;
				else a[j]++;
			}
			if(abs(poz - a[0]) == 1)ziv = false;
		} 
		else if(poz - a[i] == 1)
			s[i].push_back(2);
			d++;
			brp++;
			a.pop_back();
			for(j = 0; j < a.size(); j++){
				if(a[j] >= 0) a[j]--;
				else a[j]++;
			}
			if(abs(poz - a[0]) == 1)ziv = false;
		else {
			s[i].push_back(3);
			brp++;
			poz++;
			for(j = 0; j < a.size(); j++){
				if(a[j] >= 0) a[j]--;
				else a[j]++;
			}
		}
	}
	cout << d << '\n';
	return 0;
}