#include <bits/stdc++.h>
using namespace std;
int main() {
  int sizePermute, sizebkp, x, minimum = 100, maximum = 0, maximumIndex,
                               minimumIndex, counter = 0;
  cin >> sizePermute;
  sizebkp = sizePermute;
  vector<int> myvec(sizePermute);
  myvec.clear();
  while (sizePermute != 0) {
    cin >> x;
    if (x < minimum) {
      minimum = x;
      minimumIndex = counter;
    }
    if (x > maximum) {
      maximum = x;
      maximumIndex = counter;
    }
    myvec.push_back(x);
    sizePermute--;
    counter++;
  }
  if (maximumIndex == (sizebkp - 1) && minimumIndex == 0) {
    cout << sizebkp - 1 << endl;
    return 0;
  } else if (minimumIndex == (sizebkp - 1) && maximumIndex == 0) {
    cout << sizebkp - 1 << endl;
    return 0;
  } else if (maximumIndex < minimumIndex &&
             (((sizebkp - 1) - minimumIndex) > (maximumIndex - 0))) {
    cout << sizebkp - 1 - maximumIndex << endl;
    return 0;
  } else if (maximumIndex < minimumIndex &&
             (((sizebkp - 1) - minimumIndex) < (maximumIndex - 0))) {
    cout << minimumIndex << endl;
    return 0;
  } else if (maximumIndex > minimumIndex &&
             (((sizebkp - 1) - maximumIndex) > (minimumIndex - 0))) {
    cout << sizebkp - 1 - minimumIndex << endl;
    return 0;
  } else if (maximumIndex > minimumIndex &&
             (((sizebkp - 1) - maximumIndex) < (minimumIndex - 0))) {
    cout << maximumIndex << endl;
    return 0;
  } else if (maximumIndex > minimumIndex &&
             (((sizebkp - 1) - maximumIndex) == (minimumIndex - 0))) {
    cout << sizebkp - 1 - minimumIndex << endl;
    return 0;
  } else if (maximumIndex < minimumIndex &&
             (((sizebkp - 1) - minimumIndex) == (maximumIndex - 0))) {
    cout << sizebkp - 1 - maximumIndex << endl;
    return 0;
  }
}
