#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 = 4;
  std::vector<int> X;
  if(s1.size() && s2.size()) {
    int prvl = *s1.begin();
    int prvr = *s2.begin();
    if(prvl != 1 && prvr == 1) {
      X.push_back(2);
      ans += 1;
      s2.erase(prvr);
      p = 1;
    }
  }
  while(t--) {
    if(!s1.size() && !s2.size()) {
      break;
    }
    if(!s1.size()) {
      if(p == 4) {
        p = 0;
      }
      if(p == 0) {
        int prev = *s2.begin();
        if(prev - h > pos) {
          ans += 1;
          h += 1;
          p = 1;
          s2.erase(prev);
          X.push_back(2);
        }
        else {
          break;
        }
      }
      else {
        int prev = *s2.begin();
        if(prev - h <= pos) {
          break;
        }
        h += 1;
        p = 0;
        X.push_back(1);
      }
      continue;
    }
    if(!s2.size()) {
      if(p == 4) {
        p = 2;
      }
      if(p == 2) {
        int prev = *s1.begin();
        if(prev - h > pos) {
          ans += 1;
          p = 0;
          h += 1;
          s1.erase(prev);
          X.push_back(1);
        }
        else {
          break;
        }
      }
      else {
        int prev = *s1.begin();
        if(prev - h <= pos) {
          break;
        }
        X.push_back(3);
        pos -= 1;
        p = 2;
        h += 1;
      }
      continue;
    }
    if(p == 4) {
      p = 1;
    }
    int prv1 = *s1.begin();
    int prv2 = *s2.begin();
    if(prv1 - h <= pos || prv2 - h <= pos) {
      break;
    }
    if(p == 1) {
      int prev = *s1.begin();
      ans += 1;
      s1.erase(prev);
      p = 0;
      X.push_back(1);
      h += 1;
    }
    else {
      int prev = *s2.begin();
      ans += 1;
      s2.erase(prev);
      p = 1;
      X.push_back(2);
      h += 1;
    }
  }
  std::cout << ans << "\n";
  return 0;
  for(auto w : X) {
    if(w == 1) {
      std::cout << 2;
    }
    else if(w == 2) {
      std::cout << 1;
    }
    else {
      std::cout << 3;
    }
  }
}