#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int wz1, wz2;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    if (temp == 1) wz1 = i;
    if (temp == n) wz2 = i;
  }
  int minn = min(wz1, wz2);
  int ans = n - minn - 1;
  int maxn = max(wz1, wz2);
  ans = max(ans, maxn);
  cout << ans << endl;
}
