#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, start = 0, end = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x == 1) {
      start = i + 1;
    }
    if (x == n) {
      end = i + 1;
    }
  }
  cout << max({abs(end - n), abs(end - 1), abs(start - 1), abs(start - n)});
}
int main() {
  int t = 1;
  while (t--) {
    solve();
    cout << '\n';
  }
}
