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


void main() {
    int n;
    scan(n);
    auto jisa = readln.split.to!(int[]);
    jisa.sort();

    if (n >= 24) {
        writeln(0);
        return;
    }
    else if (n >= 12) {
        auto cnt = new int[](24);

        foreach (i ; 0 .. n) {
            cnt[jisa[i]]++;
        }

        bool z = (cnt[0] > 0);

        foreach (i ; 1 .. 24) {
            if (cnt[i] > 2) z = true;
        }

        writeln(z ? 0 : 1);

        return;
    }

    auto d = new int[](n);

    int ans = 0;

    foreach (cmb ; 0 .. (1<<n)) {
        foreach (i ; 0 .. n) {
            if (cmb & (1<<i)) {
                d[i] = jisa[i];
            }
            else {
                d[i] = 24 - jisa[i];
            }
        }

        int mindf = jisa[0];

        foreach (i ; 0 .. n) {
            foreach (j ; i + 1 .. n) {
                int df = abs(d[i] - d[j]);
                mindf = min(mindf, min(df, 24 - df));
            }
        }

        ans = max(ans, mindf);
    }

    writeln(ans);
}



struct UnionFind {
    private {
        int N;
        int[] p;
        int[] rank;
    }

    this (int n) {
        N = n;
        p = iota(N).array;
        rank = new int[](N);
    }

    int find_root(int x) {
        if (p[x] != x) {
            p[x] = find_root(p[x]);
        }

        return p[x];
    }

    bool same(int x, int y) {
        return find_root(x) == find_root(y);
    }

    void unite(int x, int y) {
        int u = find_root(x), v = find_root(y);

        if (u == v) return;

        if (rank[u] < rank[v]) {
            p[u] = v;
        }
        else {
            p[v] = u;

            if (rank[u] == rank[v]) {
                rank[u]++;
            }
        }
    }
}


void scan(T...)(ref T args) {
    string[] 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);
        }
    }
}



struct Queue(T) {
    private {
        int N, head, tail;
        T[] data;
    }

    this(int n) {
        N = n + 1;
        data = new T[](N);
    }

    bool empty() {
        return head == tail;
    }

    bool full() {
        return (tail + 1) % N == head;
    }

    T front() {
        return data[head];
    }

    void push(T x) {
        assert(!full);
        data[tail++] = x;
        tail %= N;
    }

    void pop() {
        assert(!empty);
        head = (head + 1) % N;
    }

    void clear() {
        head = tail = 0;
    }
}