#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, head, tail;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    if (x == 1) head = i;
    if (x == n) tail = i;
  }
  int res = fabs(1 - head);
  if (res < fabs(1 - tail)) res = fabs(1 - tail);
  if (res < fabs(n - tail)) res = fabs(n - tail);
  if (res < fabs(n - head)) res = fabs(n - head);
  cout << res;
  return 0;
}
