#include <bits/stdc++.h>
int main() {
  int n, li, hi, d, i;
  int dist[4];
  scanf("%d", &n);
  int ary[n];
  for (i = 0; i < n; i++) {
    scanf("%d", &ary[i]);
  }
  for (li = 0; li < n; li++) {
    if (ary[li] == 1) break;
  }
  for (hi = 0; hi < n; hi++) {
    if (ary[hi] == n) break;
  }
  if (fabs(hi - li) == n - 1)
    printf("%d", n - 1);
  else {
    dist[0] = fabs(0 - hi);
    dist[1] = fabs((n - 1) - hi);
    dist[2] = fabs(0 - li);
    dist[3] = fabs((n - 1) - li);
    d = fabs(hi - li);
    for (i = 0; i < 4; i++) {
      if (dist[i] > d) d = dist[i];
    }
    printf("%d", d);
  }
  return 0;
}
