#include <bits/stdc++.h>
using namespace std;
int a[105];
int n, mi, ni;
int main() {
  cin >> n;
  int mx = 0, mn = 110, mi = 0, ni = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (mx < a[i]) {
      mx = a[i];
      mi = i;
    }
    if (mn > a[i]) {
      ni = i;
      mn = a[i];
    }
  }
  int ans;
  int indx, l, r;
  if (mi > ni) {
    l = n - 1 - mi;
    r = ni;
  } else {
    l = n - 1 - ni;
    r = mi;
  }
  ans = max(l, r);
  ans = ans + abs(mi - ni);
  cout << ans << endl;
  return 0;
}
