#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i, j, l, u, v, w, x, y, z, a, b, c, d, e, f, t = 1, tc;
  long long flg, sz, cnt, gt, ans, mx, mn;
  long long m, k, n;
  long long low, hi, md, sm, ff, inp[200007];
  scanf("%lld", &n);
  for (i = 0; i < n; i++) scanf("%lld", &inp[i]);
  ans = -9999999999999;
  for (j = 0; j < n; j++) {
    if (inp[j] == 1) a = j;
    if (inp[j] == n) b = j;
  }
  if (a > b) swap(a, b);
  ans = abs(b - 0);
  ans = max(ans, n - 1 - a);
  cout << ans << endl;
  return 0;
}
