#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, arr[105];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  int mx, mn, minn, maxx, x, y;
  mx = mn = arr[0];
  for (int i = 0; i < n; i++) {
    if (mx < arr[i]) mx = arr[i];
    if (mn > arr[i]) mn = arr[i];
  }
  for (int i = 0; i < n; i++) {
    if (arr[i] == mn)
      minn = i;
    else if (arr[i] == mx)
      maxx = i;
  }
  if ((minn == 0 && maxx == n - 1) || (maxx == 0 && minn == n - 1)) {
    cout << abs(minn - maxx);
    return 0;
  } else if (maxx > minn) {
    x = n - 1 - minn;
    y = maxx - 0;
  } else if (minn > maxx) {
    x = n - 1 - maxx;
    y = minn - 0;
  }
  cout << max(x, y);
}
