#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, y = 105, x = 0, p, q;
  cin >> n;
  int a[n], b[4];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > x) {
      x = a[i];
      p = i + 1;
    }
    if (a[i] < y) {
      y = a[i];
      q = i + 1;
    }
  }
  b[0] = p - 1;
  b[1] = n - p;
  b[2] = q - 1;
  b[3] = n - q;
  sort(b, b + 4, greater<int>());
  cout << b[0];
  return 0;
}
