#include <bits/stdc++.h>
using namespace std;
long long gcd(long long, long long);
int main() {
  long long n, ans[1000000], i, max, min, p = 1, z = 1, a[5];
  cin >> n;
  i = 1;
  for (i; i <= n; i++) cin >> ans[i];
  max = ans[1];
  min = ans[1];
  i = 1;
  for (i; i <= n; i++) {
    if (ans[i] > max) {
      max = ans[i];
      p = i;
    }
    if (ans[i] < min) {
      min = ans[i];
      z = i;
    }
  }
  if (p - z == n - 1 || z - p == n - 1) {
    cout << n - 1;
    return 0;
  }
  a[0] = abs(n - p);
  a[1] = abs(n - z);
  a[2] = abs(1 - p);
  a[3] = abs(1 - z);
  i = 0;
  max = a[0];
  for (i; i <= 4; i++) {
    if (a[i] > max) max = a[i];
  }
  cout << max;
  return 0;
}
long long gcd(long long u, long long v) {
  while (v != 0) {
    long long r = u % v;
    u = v;
    v = r;
  }
  return u;
}
