#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int n, a[N], ma = -N, me = N, idx_ma, idx_me;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > ma) {
      ma = a[i];
      idx_ma = i;
    }
    if (a[i] < me) {
      me = a[i];
      idx_me = i;
    }
  }
  int ans = abs(idx_me - idx_ma);
  for (int i = 0; i < n; i++) {
    ans = max(ans, abs(i - idx_ma));
    ans = max(ans, abs(i - idx_me));
  }
  cout << ans << "\n";
  return 0;
}
