import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto ds = readln.split.to!(int[]);
    sort(ds);
    if (N > 23 || ds[0] == 0) {
        writeln(0);
        return;
    }
    bool[24] T;
    T[0] = true;
    int solve(int i) {
        if (i == N) {
            int r = 12, j;
            foreach (k, b; T) if (k && b) {
                r = min(r, k - j, 24 - j + k);
                j = k.to!int;
            }
            return r;
        } else {
            int r1, r2;
            if (!T[ds[i]]) {
                T[ds[i]] = true;
                r1 = solve(i+1);
                T[ds[i]] = false;
            }
            if (!T[24-ds[i]]) {
                T[24-ds[i]] = true;
                r2 = solve(i+1);
                T[24-ds[i]] = false;
            }
            return max(r1, r2);
        }
    }
    writeln(solve(0));
}