#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int _min = 0, _max = 0;
  for (int i = 0; i < n; ++i) {
    int tmp;
    cin >> tmp;
    if (tmp == 1)
      _min = i;
    else if (tmp == n)
      _max = i;
  }
  int ans = abs(_min - _max);
  if (_max != 0) ans = max(ans, _max);
  if (_max != n - 1) ans = max(ans, n - 1 - _max);
  if (_min != 0) ans = max(ans, _min);
  if (_min != n - 1) ans = max(ans, n - 1 - _min);
  cout << ans << endl;
  return 0;
}
