#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void resolve() {
    int n;
    cin >> n;
    VI d(n);
    REP(i,0,n) cin >> d[i];
    int ans = -1, ans2 = 12;
    VI diff(13);
    REP(i,0,n) {
        if (d[i] == 12) diff[12]++;
        else diff[d[i] % 12]++;
    }
    REP(i,0,12) {
        int tmp = 12;
        if (diff[i] > 2) tmp = 0;
        else if (diff[i] >= 1) {
            if (diff[12] > 0) tmp = min(tmp, 12 - i);
            tmp = min(tmp, i);
            if (diff[i] == 2) {
                tmp = min(tmp, 24 - 2 * i);
            }
        }
        //cerr << tmp << endl;
        ans2 = min(ans2, tmp);
    }
    if (diff[12] > 1) ans2 = 0;
    dump(ans2);
    REP(b,0,1<<12) {
        int tmp = 12;
        bool bo = false;
        //cerr << tmp << endl;
        REP(i,1,12) REP(j,i+1,12) {
            if (diff[i] == 0 || diff[j] == 0) continue;
            int di = (b & (1 << i)) ? i : 24 - i;
            int dj = (b & (1 << j)) ? j : 24 - j;
            tmp = min(tmp, abs(dj - di));
            bo = true;
            //cerr << i << " " << j << " " << di << " " << dj << endl;
        }
        //cerr << tmp << endl;
        if (bo) ans = max(ans, tmp);
        //break;
    }
    cout << min(ans2, (ans > -1) ? ans : 12) << endl;
}

int main() {
    resolve();
    
    return 0;
}