#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

#define rep(i, a) for (int i = 0; i < (a); i++)
#define ll long long

int N;
int d[55], cnt[13];
vector<int> v;

int diff(ll mask) {
  int res = 12;
  rep(i, 25) {
    if (!(mask & (1LL << i))) continue;
    for (int j = i + 1; j < 25; j++) {
      if (!(mask & (1LL << j))) continue;
      int d = (i - j + 24) % 24;
      res = min(res, min(d, 24 - d));
    }
  }
  //printf("%d, %llx\n", res, mask);
  return res;
}

int dfs(int i, ll mask) {
  int res = 0;
  if (i > v.size() - 1) return diff(mask);

  if (!(mask & (1LL << v[i]))) {
    res = max(res, dfs(i + 1, mask | (1LL << v[i])));
  }
  if (!(mask & (1LL << (24 - v[i])))) {
    res = max(res, dfs(i + 1, mask | (1LL << (24 - v[i]))));
  }
  return res;
}

int solve(){
  if (cnt[0] > 0) return 0;
  rep(i, 13) if (cnt[i] >= 3) return 0;
  rep(i, 13) rep(j, cnt[i]) v.push_back(i);

  return dfs(0, 1);
}

int main(void) {
  cin >> N;
  rep(i, N) cin >> d[i], cnt[d[i]]++;
  
  cout << solve() << endl;

  return 0;
}
