#include <bits/stdc++.h>
using namespace std;
int n;
int Min = 1e5, Max;
int l, r;
int t;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> t;
    if (t < Min) {
      Min = t;
      l = i;
    }
    if (t > Max) {
      Max = t;
      r = i;
    }
  }
  if (r < l) {
    int x = l;
    l = r;
    r = x;
  }
  cout << max(n - 1 - l, r);
  return 0;
}
