#include <bits/stdc++.h>
using namespace std;
int n, a[110];
int calc() {
  int pos1 = 0, pos2 = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] == 1) pos1 = i;
    if (a[i] == n) pos2 = i;
  }
  return abs(pos1 - pos2);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      swap(a[i], a[j]);
      ans = max(ans, calc());
      swap(a[i], a[j]);
    }
  printf("%d\n", ans);
  return 0;
}
