#include <bits/stdc++.h>
using namespace std;
int ret_abs(int x, int y) {
  if (x > y) {
    return x - y;
  } else {
    return y - x;
  }
}
int ret_max(int a, int b, int c, int d, int e) {
  int max = 0;
  if (a > max) {
    max = a;
  }
  if (b > max) {
    max = b;
  }
  if (c > max) {
    max = c;
  }
  if (d > max) {
    max = d;
  }
  if (e > max) {
    max = e;
  }
  return max;
}
int main() {
  int n;
  cin >> n;
  vector<int> arr;
  int x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    arr.push_back(x);
  }
  vector<int>::iterator min, max;
  min = find(arr.begin(), arr.end(), 1);
  max = find(arr.begin(), arr.end(), n);
  int num_min = min - arr.begin();
  int num_max = max - arr.begin();
  int diff1, diff2, diff3, diff4, diff5;
  diff1 = ret_abs(num_max, num_min);
  diff2 = ret_abs(num_max, 0);
  diff3 = ret_abs(num_max, n - 1);
  diff4 = ret_abs(num_min, 0);
  diff5 = ret_abs(num_min, n - 1);
  int ans = ret_max(diff1, diff2, diff3, diff4, diff5);
  cout << ans << endl;
  return 0;
}
