#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, ps1, ps2;
  scanf("%d", &n);
  int ar[n + 4];
  for (i = 0; i < n; i++) {
    scanf("%d", &ar[i]);
    if (ar[i] == 1)
      ps1 = i;
    else if (ar[i] == n)
      ps2 = i;
  }
  int ans = max(
      abs(ps2 - ps1),
      max(abs(ps2), max(abs(ps1), max(abs(ps1 - n + 1), abs(ps2 - n + 1)))));
  printf("%d\n", ans);
}
