#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > v;
map<int, int> mpp;
map<int, int>::iterator it;
set<string> s;
set<pair<int, int> >::iterator iter;
int gcd(int a, int b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
bool isprime(long long p) {
  if (p < 2) return false;
  if (p == 2) return true;
  if (p % 2 == 0) return false;
  double limit = sqrt(p);
  for (long long i = 3; i <= limit; i += 2) {
    if ((p % i) == 0) return false;
  }
  return true;
}
int n, m;
vector<vector<long long> > d(31, vector<long long>(5));
void calc(int x = 0, int y = 0, int mask = 0, int next_mask = 0) {
  if (x == n) return;
  if (y >= m)
    d[x + 1][next_mask] += d[x][mask];
  else {
    int my_mask = 1 << y;
    if (mask & my_mask)
      calc(x, y + 1, mask, next_mask);
    else {
      calc(x, y + 1, mask, next_mask | my_mask);
      if (y + 1 < m && !(mask & my_mask) && !(mask & (my_mask << 1)))
        calc(x, y + 2, mask, next_mask);
    }
  }
}
long long fac(long long n) {
  long long an = 1;
  while (n > 1) {
    an *= n;
    n--;
  }
  return an;
}
long long a[100];
int main() {
  ios::sync_with_stdio(false);
  long long n, mn = 100500, mx = 0, mni, mxi;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i] > mx) {
      mx = a[i];
      mxi = i;
    }
    if (a[i] < mn) {
      mn = a[i];
      mni = i;
    }
  }
  if (mni > mxi) swap(mni, mxi);
  long long an = max(mxi, n - mni - 1);
  if (abs(mni - mxi) > an) an = abs(mni - mxi);
  cout << an;
  return 0;
}
