#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >> a;
  vector<int> b(a);
  vector<int> c(a);
  for (int i = 0; i < a; i++) {
    cin >> b[i];
    c[i] = b[i];
  }
  sort(b.begin(), b.end());
  int i0 = 0, i1 = 0;
  for (int i = 0; i < a; i++) {
    if (c[i] == b[0]) i0 = i;
    if (c[i] == b[a - 1]) i1 = i;
  }
  i1++;
  i0++;
  cout << max(max(max(abs(a - i0), abs(a - i1)), abs(1 - i0)), abs(1 - i1));
}
