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