#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    int ok = 0, ng = d[0] + 1;
    while (ng - ok > 1) {
        int mid = (ng + ok) / 2;
        vector<int> t(n, -1);
        int cur = 0;
        for (int i = 0; i < n; i++) {
            if (d[i] - cur >= mid) {
                cur = d[i];
                t[i] = d[i];
            } else {
                t[i] = 24 - d[i]; 
            }
        }
        bool flag = true;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                int tmp = abs(t[i] - t[j]);
                if (min(tmp, 24 - tmp) < mid) {
                    flag = false;
                    break;
                }
            }
            if (!flag) break;
        }
        if (flag) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
    return 0;
}