#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, idx = 0, ans = 0, ans1 = 0;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    if (a[i] <= 500000) {
      ans = a[i] - 1;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] > 500000) {
      ans1 = 1000000 - a[i];
    }
  }
  cout << max(ans, ans1);
}
