#include <bits/stdc++.h>
int maxa(int a, int b) {
  if (a >= b)
    return (a);
  else
    return (b);
}
int main() {
  int i, j, min, max, a[105], maxi, mini, n;
  scanf("%d", &n);
  min = 101;
  max = 0;
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (max < a[i]) {
      max = a[i];
      maxi = i;
    }
    if (min > a[i]) {
      min = a[i];
      mini = i;
    }
  }
  printf("%d", maxa(maxa(abs(mini - 1), abs(mini - n)),
                    maxa(abs(maxi - 1), abs(maxi - n))));
  return 0;
}
