#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main(int argc, char** argv) {
  int n;
  cin >> n;
  int x = 0, y = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] == 1) x = i;
    if (a[i] == n) y = i;
  }
  cout << max(abs(x - y), max(abs(1 - x), max(abs(1 - y), max(n - x, n - y))));
  return 0;
}
