#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  int v;
  int a = 0;
  int b = 0;
  scanf(" %d", &n);
  for (int i = 1; i <= n; i++) {
    scanf(" %d", &v);
    if (v == 1) {
      a = i;
    } else if (v == n) {
      b = i;
    }
  }
  int r = max(n - a, max(n - b, max(a - 1, b - 1)));
  printf("%d\n", r);
  return 0;
}
