import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    int N;
    scan(N);
    auto d = readln.split.to!(int[]);

    auto cnt = new int[](13);
    foreach (di ; d) {
        cnt[di]++;
    }

    if (cnt[0] > 0) {
        writeln(0);
        return;
    }
    if (cnt.any!"a > 2") {
        writeln(0);
        return;
    }

    int ans;

    int f(int[] s) {
        auto ss = s.dup.sort();
        int res = inf;
        foreach (i ; 0 .. ss.length.to!int - 1) {
            chmin(res, ss[i + 1] - ss[i]);
        }
        return res;
    }

    void dfs(int i, int[] s) {
        if (i == 13) {
            debug {
                writeln(s);
            }
            chmax(ans, f(s));
            return;
        }
        auto ss = s.dup;
        if (cnt[i] > 1) {
            ss ~= [i, 24 - i];
            dfs(i + 1, ss);
        }
        else if (cnt[i] == 1) {
            auto ssa = ss.dup ~ [i];
            dfs(i + 1, ssa);
            auto ssb = ss.dup ~ [24 - i];
            dfs(i + 1, ssb);
        }
        else {
            dfs(i + 1, ss);
        }
    }

    dfs(1, [0, 24]);

    writeln(ans);
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}
