#include <bits/stdc++.h>
using namespace std;
const int MAX = 12;
int n, a, sol;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    if (a > 1 && a < n) continue;
    sol = max(sol, max(n - i, i - 1));
  }
  cout << sol << '\n';
}
