#include <bits/stdc++.h>
using namespace std;
int num[101];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int pos, index;
  for (int i = 0; i < n; i++) {
    cin >> num[i];
    if (num[i] == 1) index = i;
    if (num[i] == n) pos = i;
  }
  int ans = max(abs(n - 1 - index), abs(index - 0));
  int res = max(abs(n - 1 - pos), abs(pos - 0));
  cout << max(ans, res) << endl;
  return 0;
}
