#include <bits/stdc++.h>
int main() {
  int n, a, mx = 0, mn = 100, i, x, y;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a);
    if (a > mx) {
      mx = a;
      x = i;
    }
    if (a < mn) {
      mn = a;
      y = i;
    }
  }
  mx = x > y ? x : y;
  mn = x < y ? x : y;
  mx = n - mx + 1;
  x = mx < mn ? mx : mn;
  printf("%d\n", n - x);
  return 0;
}
