#include <bits/stdc++.h>
using namespace std;
int main() {
  int t = 1;
  while (t--) {
    int n;
    cin >> n;
    int a[n];
    int min1, max1;
    for (int i = 0; i < n; i++) cin >> a[i];
    min1 = 0;
    max1 = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] < a[min1]) min1 = i;
      if (a[i] > a[max1]) max1 = i;
    }
    int r = abs(min1 - max1);
    r = max(abs(0 - max1), r);
    r = max(abs(0 - min1), r);
    r = max(abs(n - 1 - max1), r);
    r = max(abs(n - 1 - min1), r);
    cout << r << endl;
  }
}
