#include <bits/stdc++.h>
using namespace std;
const int INF = 1LL << 30;
const long long int LLINF = 1LL << 60;
int n, v[50];
int nowmin = 0;
void f(bitset<50> b, int p) {
  if (n == 1) nowmin = v[0];
  if (p == n - 1) {
    vector<int> vv;
    for (int i = (long long int)0; i < (long long int)n; ++i)
      vv.push_back(b[i] ? 24 - v[i] : v[i]);
    sort(vv.begin(), vv.end());
    int minn = vv[0];
    for (int i = (long long int)0; i < (long long int)n; ++i) {
      for (int j = 1 + i; j < n; ++j) {
        if (abs(vv[i] - vv[j]) < minn) minn = abs(vv[i] - vv[j]);
      }
    }
    nowmin = max(nowmin, minn);
  } else {
    f(b, p + 1);
    bitset<50> b2 = b;
    b2[p] = 1;
    f(b2, p + 1);
  }
}
int main() {
  bitset<50> b = {};
  cin >> n;
  int ct[12] = {};
  int m = 0;
  for (int i = (long long int)0; i < (long long int)n; ++i) {
    cin >> v[i];
    ct[v[i] - 1]++;
    if (ct[v[i] - 1] == 3) {
      cout << 0 << endl;
      return 0;
    }
    if (ct[v[i] - 1] == 2 && m < v[i] - 1) m = v[i] - 1;
  }
  sort(v, v + n);
  if (m != 0) {
    m += 1;
    if (m >= 6)
      cout << 24 - m * 2 << endl;
    else
      cout << v[0] << endl;
    return 0;
  }
  f(b, 0);
  cout << nowmin << endl;
  return 0;
}
