#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
long long lcm(long long a, long long b) { return (a * (b / gcd(a, b))); }
long long POWER(long long x, long long y, long long m) {
  if (y == 0) return 1;
  if (y % 2 == 0) {
    long long temp = POWER(x, y / 2, m);
    temp *= temp;
    temp %= m;
    return temp;
  }
  long long temp = POWER(x, y - 1, m);
  temp *= x;
  temp %= m;
  return temp;
}
long long POWER(long long x, long long y) {
  if (y == 0) return 1;
  if (y % 2 == 0) {
    long long temp = POWER(x, y / 2);
    temp *= temp;
    return temp;
  }
  long long temp = POWER(x, y - 1);
  temp *= x;
  return temp;
}
int ans[6];
int a[111];
int main() {
  ifstream fin("input.txt");
  ofstream fout("output.txt");
  int n;
  cin >> n;
  int s, e;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] == 1) s = i;
    if (a[i] == n) e = i;
  }
  ans[0] = abs(s - e);
  ans[1] = (abs(n - s));
  ans[2] = (abs(1 - s));
  ans[3] = (abs(n - e));
  ans[4] = (abs(1 - e));
  int x = 0;
  for (int i = 0; i < 5; i++) x = max(x, ans[i]);
  cout << x << '\n';
}
