#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[102], m, n, i, index, index1, mini = -1, maxi = 100000, res, res1;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (i = 1; i <= n; i++) {
    if (a[i] > mini) {
      mini = a[i];
      index = i;
    }
    if (a[i] < maxi) {
      maxi = a[i];
      index1 = i;
    }
  }
  int b[5];
  maxi = -1;
  b[0] = abs(1 - index);
  b[1] = abs(1 - index1);
  b[2] = abs(n - index);
  b[3] = abs(n - index1);
  for (i = 0; i < 4; i++) {
    if (b[i] > maxi) maxi = b[i];
  }
  cout << maxi;
  return 0;
}
