#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, vtmin = 0, vtmax = 0, a[101] = {0}, minn = 10100, maxx = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (minn > a[i]) {
      minn = a[i];
      vtmin = i;
    }
    if (maxx < a[i]) {
      maxx = a[i];
      vtmax = i;
    }
  }
  if (vtmin < vtmax)
    cout << max(vtmax, n - 1 - vtmin);
  else
    cout << max(vtmin, n - 1 - vtmax);
  return 0;
}
