#include <bits/stdc++.h>
using namespace std;
int main() {
  string k, p;
  long long a, b, c = 0, d = 0, e = 0, f = 0, g = 8, h, i, j = -1, l, m, n, o,
                  q, r, t, u, v, w, x, y, z;
  cin >> a;
  for (i = 0; i < a; i++) {
    cin >> b;
    if (b == a) {
      c = i;
    }
    if (b == 1) {
      d = i;
    }
  }
  cout << max(max(a - c - 1, a - d - 1), max(c, d));
}
