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