#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <regex>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int main() {
    int n;
    cin >> n;
    VI v(n + 1, 0);
    REP(i,n) {
        cin >> v[i + 1];
    }
    
    sort(v.begin(), v.end());
    REP(i,v.size()) {
        if (i % 2 == 0) {
            v[i] = 24 - v[i];
        }
    }
    
    long ans = 24;
    REP(i,v.size()) {
        REPI(j,i+1,v.size()) {
            long d = abs(v[j] - v[i]);
            ans = min(ans, min(d, 24 - d));
        }
    }
    cout << ans << endl;
}
