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