#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int INF = 1e9;
const double EPS = 1e-8;
int a[105];
int main() {
  int n;
  scanf("%d", &(n));
  int t;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &(t));
    a[t] = i;
  }
  cout << max(n - a[1], max(n - a[n], max(a[n] - 1, a[1] - 1))) << endl;
}
