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