#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  int min = arr[0];
  int max = arr[0];
  int pos_min = 0;
  int pos_max = 0;
  for (int i = 0; i < n; i++)
    if (arr[i] > max) {
      max = arr[i];
      pos_max = i;
    }
  for (int i = 0; i < n; i++)
    if (arr[i] < min) {
      min = arr[i];
      pos_min = i;
    }
  int rast = 0;
  for (int i = 0; i < n; i++)
    if (abs(pos_min - i) > rast) rast = abs(pos_min - i);
  for (int i = 0; i < n; i++)
    if (abs(pos_max - i) > rast) rast = abs(pos_max - i);
  rast = (rast > abs(pos_min - pos_max)) ? rast : abs(pos_min - pos_max);
  cout << rast;
  return 0;
}
