#include <bits/stdc++.h>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
template <ostream& out = cout, class... T>
void prints(T&&...) {}
template <ostream& out = cout, class... T>
void printe(T&&...) {}
template <ostream& out = cout, class... T>
void printw(T&&...) {}
template <ostream& out = cout, class... T>
void printew(T&&...) {}
template <ostream& out = cout, class... T>
void printb(T&&...) {}
template <ostream& out = cout, class... T>
void printd(T&&...) {}
template <ostream& out = cout, class... T>
void printde(T&&...){};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> ds(n);
  for (int i = 0; i < n; i++) {
    cin >> ds[i];
  }
  vector<char> dp(1 << 24);
  dp[1] = true;
  for (int i = 0; i < n; i++) {
    vector<char> next(1 << 24);
    int d = ds[i];
    if (!d) {
      cout << 0 << '\n';
      return 0;
    }
    for (int bits = 0; bits < (1 << 24); bits++) {
      if (!dp[bits]) {
        continue;
      }
      if ((bits >> d & 1) == 0) {
        next[bits | (1 << d)] = true;
      }
      if ((bits >> (24 - d) & 1) == 0) {
        next[bits | (1 << (24 - d))] = true;
      }
    }
    dp.swap(next);
  }
  int ans = 0;
  for (int bits = 0; bits < (1 << 24); bits++) {
    if (!dp[bits]) {
      continue;
    }
    printb(bits);
    vector<int> v;
    for (int i = 0; i < 24; i++) {
      if (bits >> i & 1) {
        v.push_back(i);
      }
    }
    prints(v);
    int cand = M;
    if (v.size() <= 1) {
      exit(1);
    }
    for (size_t i = 0; i < v.size(); i++) {
      cand = min(cand, abs(v[i] - v[(i + v.size() - 1) % v.size()]));
      printd(cand, i);
    }
    ans = max(ans, cand);
  }
  cout << ans << '\n';
}
