#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, smallest = 0, largest = 0, in;
  cin >> n;
  vector<int> num;
  cin >> in;
  num.push_back(in);
  for (int i = 1; i < n; i++) {
    cin >> in;
    num.push_back(in);
    if (in < num[smallest])
      smallest = i;
    else if (in > num[largest])
      largest = i;
  }
  if (smallest <= n / 2 && largest <= n / 2) {
    cout << n - 1 - min(smallest, largest) << endl;
  } else if (smallest >= n / 2 && largest >= n / 2) {
    cout << max(smallest, largest) << endl;
  } else {
    cout << max(n - 1 - min(smallest, largest), max(smallest, largest)) << endl;
  }
  return 0;
}
