#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, i, a, b, min, sum, max, num[105];
  while (~scanf("%d", &n)) {
    for (i = 1; i <= n; i++) scanf("%d", &num[i]);
    min = max = num[1];
    a = b = 1;
    for (i = 1; i <= n; i++) {
      if (max < num[i]) max = num[i], a = i;
      if (min > num[i]) min = num[i], b = i;
    }
    if (a > b) i = a, a = b, b = i;
    if (a - 1 < n - b)
      printf("%d\n", n - a);
    else
      printf("%d\n", b - 1);
  }
}
