#include <bits/stdc++.h>
using namespace std;
int maxx(int fd, int sd) { return (fd > sd) ? fd : sd; }
int main() {
  int n;
  vector<int> a;
  scanf("%d", &n);
  int min = 0;
  int max = 0;
  for (int i = 0; i < n; ++i) {
    int cur;
    scanf("%d", &cur);
    a.push_back(cur);
    if (cur < a[min]) min = i;
    if (cur > a[max]) max = i;
  }
  if (min > max) {
    int t = min;
    min = max;
    max = t;
  }
  printf("%d", maxx(n - 1 - min, max));
  return 0;
}
