#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, a[100], n, m, ans = 0, j1, j2, t1, t2;
  cin >> x;
  for (int i = 0; i < x; i++) {
    cin >> a[i];
    if (a[i] == 1) n = i;
    if (a[i] == x) m = i;
  }
  if (n == 0 || m == 0 || n == x - 1 || m == x - 1)
    ans = x - 1;
  else {
    j1 = m > n ? m : n;
    t1 = x - j1 - 1;
    j2 = m < n ? m : n;
    t2 = j2;
    if (t2 >= t1) {
      ans = j1;
    } else if (t1 > t2) {
      ans = x - 1 - t2;
    }
  }
  cout << ans << endl;
  return 0;
}
