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