#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int pos = 0;
  int x;
  int t = ((n + 1) / 2) - 1;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x == 1 || x == n) {
      if (i == t)
        pos = max(pos, 0);
      else if (i < t) {
        pos = max(pos, n - i - 1);
      } else {
        pos = max(i, pos);
      }
    }
  }
  cout << pos;
}
