#include <bits/stdc++.h>
using namespace std;
const int inf_int = 2e9;
const long long inf_ll = 2e18;
int a[105];
int main() {
  int n;
  int maxn = -inf_int, minn = inf_int;
  int pos1, pos2 = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] > maxn) {
      maxn = a[i];
      pos1 = i;
    }
    if (a[i] < minn) {
      minn = a[i];
      pos2 = i;
    }
  }
  int ans = max(n - pos1, max(pos1 - 1, max(n - pos2, pos2 - 1)));
  cout << ans << endl;
  return 0;
}
