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