#include <bits/stdc++.h>
using namespace std;
int n, ans;
string s;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    if (x == 1 || x == n) ans = max(ans, max(n - i, i - 1));
  }
  cout << ans;
}
