#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;

int main(){

    int N;
    cin >> N;

    vector<int> d(N);
    rep(i, N)cin >> d[i];
    d.push_back(0);
    sort(all(d));

    vector<int> cnt(24, 0);
    int now = 1;
    rep(i, N + 1){
        if(d[i] == 0 or d[i] == 12)cnt[d[i]]++;
        else {
            if(now == 1)cnt[d[i]]++;
            else cnt[24 - d[i]]++;
            now = 1 - now;
        }
    }

    int ans = 24;
    vector<int> tmp;
    rep(i, 24)rep(j, cnt[i])tmp.push_back(i);
    rep(i, N)chmin(ans, tmp[i + 1] - tmp[i]);
    cout << ans << endl;
    return 0;

}