#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, min1, max1, ans, ans1;
  cin >> n;
  int a[n], b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(a, a + n);
  int min = a[0];
  int max = a[n - 1];
  for (int i = 0; i < n; i++) {
    if (b[i] == min) {
      min1 = i;
      break;
    }
  }
  for (int i = 0; i < n; i++) {
    if (b[i] == max) {
      max1 = i;
      break;
    }
  }
  int v = abs(n - 1 - min1);
  int w = abs(n - 1 - max1);
  if (w <= v) {
    ans = n - 1 - min1;
  } else {
    ans = n - 1 - max1;
  }
  if (min1 <= max1) {
    ans1 = max1;
  } else {
    ans1 = min1;
  }
  if (ans <= ans1) {
    cout << ans1;
  } else {
    cout << ans;
  }
}
