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

const int INF = (int)1.01e9;

int cnt[24];

int main() {
#ifdef HOME
    freopen("in", "r", stdin);
#endif

    int n;
    while (cin >> n) {
        vector<int> d(n);
        for (int i = 0; i < n; i++) {
            cin >> d[i];
        }

        if (n > 23) {
            cout << 0 << endl;
            continue;
        }
        int ans = 0;
        for (int mask = 0; mask < (1 << n); mask++) {
            memset(cnt, 0, sizeof(cnt));
            for (int i = 0; i < n; i++) {
                if (mask & (1 << i)) {
                    if (cnt[d[i]]++ > 0) break;
                } else {
                    if (cnt[(24 - d[i]) % 24]++ > 0) break;
                }
            }
            cnt[0]++;
            int mn = INF;
            int last = -INF;
            for (int i = 0; i < 2 * 24; i++) {
                if (cnt[i % 24]) {
                    if (cnt[i % 24] > 1) mn = 0;
                    mn = min(mn, i - last);
                    last = i;
                }
                if (mn == 0) break;
            }
            ans = max(ans, mn);
            if (ans == 24 / (n + 1)) break;
        }
        cout << ans << endl;
    }


#ifdef HOME
    cerr << clock() / (double)CLOCKS_PER_SEC << endl;
#endif
    return 0;
}