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