#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 + 5;
int a[MAXN], n;
int main() {
  while (scanf("%d", &n) != EOF) {
    for (int i = 1; i <= n; i++) {
      int u;
      scanf("%d", &u);
      a[u] = i;
    }
    if (a[1] > a[n]) swap(a[1], a[n]);
    int ans1 = a[n] - 1;
    int ans2 = n - a[1];
    printf("%d\n", max(ans1, ans2));
  }
  return 0;
}
