#include <bits/stdc++.h>
using namespace std;
long long int arr[1000005];
int main() {
  long long int n, i;
  cin >> n;
  for (i = 0; i < n; i++) cin >> arr[i];
  long long int minpos = 0, maxpos = 0, min1 = INT_MAX, max1 = INT_MIN;
  for (i = 0; i < n; i++) {
    if (arr[i] < min1) {
      min1 = arr[i];
      minpos = i;
    }
    if (arr[i] > max1) {
      max1 = arr[i];
      maxpos = i;
    }
  }
  long long int pos1 = min(minpos, maxpos);
  long long int pos2 = max(minpos, maxpos);
  cout << max((pos2), (n - pos1 - 1));
}
