#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int index[n + 1];
  for (int i = 1; i <= n; i++) {
    int elem;
    cin >> elem;
    index[elem] = i;
  }
  int l = index[1], r = index[n];
  cout << max(max(abs(r - 1), abs(r - n)), max(abs(l - 1), abs(l - n)));
}
