#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[100], b, c;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 1) {
      b = i;
    }
    if (a[i] == n) {
      c = i;
    }
  }
  if (b < c) {
    if (b > n - 1 - c)
      cout << c;
    else
      cout << n - 1 - b;
  } else {
    if (c > n - 1 - b)
      cout << b;
    else
      cout << n - 1 - c;
  }
  return 0;
}
