#include <bits/stdc++.h>
template <typename T>
using Vector2D = std::vector<std::vector<T>>;
template <typename T>
using Vector3D = std::vector<Vector2D<T>>;
using PairInt = std::pair<int, int>;
using PairInt64 = std::pair<int64_t, int64_t>;
using MapInt = std::map<int, int>;
using MMapInt = std::multimap<int, int>;
using MMapInt64 = std::multimap<int64_t, int64_t>;
using UMapIntString = std::unordered_map<int, std::string>;
using SetInt = std::set<int>;
using SetInt64 = std::set<int64_t>;
using SetPairInt64 = std::set<PairInt64>;
using VectorInt = std::vector<int>;
using VectorInt2D = Vector2D<int>;
using VectorInt64 = std::vector<int64_t>;
using VectorUInt64 = std::vector<uint64_t>;
using VectorInt642D = Vector2D<int64_t>;
using VectorChar = std::vector<char>;
using VectorChar2D = Vector2D<char>;
using VectorString = std::vector<std::string>;
using QueuePairInt = std::queue<PairInt>;
using QueueInt = std::queue<int>;
using VectorPairInt = std::vector<PairInt>;
using VectorPairInt64 = std::vector<PairInt64>;
using VectorPairInt2D = Vector2D<PairInt>;
using SetInt = std::set<int>;
using MSetInt = std::multiset<int>;
using UMapChar = std::map<char, int>;
using ListInt = std::list<int>;
using VectorListInt = std::vector<ListInt>;
using VectorDouble = std::vector<double>;
int dist(const VectorInt& vv) {
  int sz = vv.size();
  int mini = 0;
  int maxi = 0;
  for (int i = 0; i < sz; ++i) {
    if (vv[i] > vv[maxi]) maxi = i;
    if (vv[i] < vv[mini]) mini = i;
  }
  return std::abs(maxi - mini);
}
int main() {
  std::ios::sync_with_stdio(false);
  int n;
  std::cin >> n;
  VectorInt vv(n);
  for (auto& v : vv) {
    std::cin >> v;
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      std::swap(vv[i], vv[j]);
      ans = std::max(ans, dist(vv));
      std::swap(vv[i], vv[j]);
    }
  }
  std::cout << ans;
  return 0;
}
