#include <bits/stdc++.h>
int main() {
  int n, aux, aux_max = -1, max = -1, aux_min = 101, min = 101;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &aux);
    if (aux < aux_min) {
      min = i;
      aux_min = aux;
    }
    if (aux > aux_max) {
      max = i;
      aux_max = aux;
    }
  }
  if (max < min) {
    printf("%d\n", ((min - 1 > n - max) ? min - 1 : n - max));
  } else {
    printf("%d\n", ((max - 1 > n - min) ? max - 1 : n - min));
  }
  return 0;
}
