#include <bits/stdc++.h>
int main() {
  int n = 0;
  std::cin >> n;
  int a[101];
  int pos1 = 0, pos2 = 0;
  char h1[10];
  for (int i = 0; i < n; ++i) {
    scanf("%s", h1);
    int ai = atoi(h1);
    if (ai == 1) pos1 = i;
    if (ai == n) pos2 = i;
  }
  int max1 = std::max(n - 1 - pos1, n - 1 - pos2);
  int max2 = std::max(pos1, pos2);
  std::cout << std::max(max1, max2);
  return 0;
}
