#include <bits/stdc++.h>

#define int int64_t

signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n;
  std::cin >> n;
  std::vector<int> x(n + 1);
  std::set<int> s1, s2;
  for(int i = 1; i <= n; i++) {
    std::cin >> x[i];
    if(x[i] < 0) {
      s1.insert(-x[i]);
    }
    else {
      s2.insert(x[i]);
    }
  }
  std::sort(x.begin() + 1, x.end());
  int t = 1e6;
  int pos = 0;
  int ans = 0;
  int h = 0;
  int p = 0;
  while(t--) {
    if(!s1.size()) {
      if(!p) {
        p ^= 1;
      }
      else {
        int prv = *s2.begin();
        if(prv - h > 0) {
          ans += 1;
          h += 1;
        }
        else {
          break;
        }
      }
      break;
    }
    if(!s2.size()) {
      ans += s1.size();
      s1.clear();
      break;
    }
    if(!p) {
      int prev = *s1.begin();
      if(prev - h > 0) {
        s1.erase(prev);
        ans += 1;
      }
      else {
        break;
      }
      h += 1;
    }
    else {
      int prev = *s2.begin();
      if(prev - h > 0) {
        s2.erase(prev);
        ans += 1;
      }
      else {
        break;
      }
      h += 1;
    }
    p ^= 1;
  }
  std::cout << ans;
}