#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(2e3) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)


int main() {
    int N;
    vector<int> D;
    cin >> N;
    REP(i,N){
        int d;
        cin >> d;
        D.push_back(d);
    }
    D.push_back(0);
    D.push_back(24);
    SORT(D);
    REP(s,24){
        vector<int> t = D;
        int i=1;
        while(i<t.size()){
            int dif = abs(t[i]-t[i-1]);
            if(min(dif,24-dif)>=s){
                i++;
            }
            else{
                if(t[i]<12){
                    t.push_back(24-t[i]);
                    t.erase(t.begin()+i);
                    SORT(t);
                }
                else{
                    cout << s-1 << endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}
