#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<int, int>;
using namespace std;

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int n;
    cin >> n;
    vector<int> d, v;
    v.push_back(0);
    rep(i, n) {
        int tmp;
        cin >> tmp;
        d.push_back(tmp);
    }
    sort(d.begin(), d.end());
    rep(i, n) {
        v.push_back(d[i] * (i%2 ? -1 : 1));
    }
    sort(v.begin(), v.end());
    int ans = 1e8;
    rep(i, n) {
        ans = min(ans, v[i+1] - v[i]);
    }
    ans = min(ans, abs(v[0] + 24 - v[n]));
    cout << ans << endl;
    return 0;
}
