#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  int p, q;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] == 1) p = i;
    if (arr[i] == n) q = i;
  }
  int ans = 0;
  ans = max(n - 1 - p, n - 1 - q);
  ans = max(ans, q);
  ans = max(ans, p);
  cout << ans << endl;
  return 0;
}
