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