#include <bits/stdc++.h>
using namespace std;
string s;
int main(void) {
    std::ios::sync_with_stdio(0);
    cin.tie(), cout.tie(0);
    int a[55] = {0}, n;
    while(cin >> n) {
        for(int i = 1; i <= n; ++i)
            cin >> a[i];
        sort(a + 1, a + n + 1);
        for(int i = n; i >= 1; --i) {
            if(!(i & 1)) a[i] = 24 - a[i];
        }
        sort(a + 1, a + n + 1);
        int mn = 24;
        for(int i = 1; i <= n; ++i)
            mn = min(mn, a[i] - a[i - 1]);
        cout << mn << endl;
    }
}