#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int mn = 1, mx = n;
  int arr[4] = {};
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x == mn) {
      arr[0] = i;
      arr[1] = n - i - 1;
    }
    if (x == mx) {
      arr[2] = i;
      arr[3] = n - i - 1;
    }
  }
  cout << (*max_element(arr, arr + 4));
  return 0;
}
