#include<bits/stdc++.h>
#define PLI pair<ll,int>
#define PII pair<int, int>
#define X first
#define Y second
#define MP make_pair
#define PLL pair<ll, ll>
#define ll long long
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define N 110
#define M 1000100
const double eps = 1e-6;
using namespace std;

int Read()
{
    int x = 0, f = 1; char ch = getchar();
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
ll ReadL()
{
    ll x = 0, f = 1; char ch = getchar();
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}

int n;
int t[N];
struct Edge
{
    struct edge{ int v, nxt; }e[M];
    int tot, hd[N];
    void init(){ tot = 0; for(int i = 1; i <= 2 * n; i ++) hd[i] = 0; }
    void add(int u, int v){ e[++tot].v = v, e[tot].nxt = hd[u], hd[u] = tot; }
}e;


namespace TwoSat
{
    int dfn[N<<1], low[N<<1], times, num, bel[N<<1], top, stk[N<<1];//强连通分量缩点辅助数组
    bool ins[N<<1];//ins[u]:u是否在栈中
    int neg(int x) { return x > n ? x - n : x + n; }//返回对称点
    ///1.i和i+n表示i出现或者i不出现
    ///2.注意反向边连接:i->j和j+n->i+n必须成对出现
    ///3.注意自相矛盾边连接:条件中如果有i->j,但是j一定不会出现,那么需要连接i->i+n表示不能选择i(该边反向边是自身)
    ///4.i或者j出现的表示:i+n->j j+n->i
    void build(int x){
//        printf("%d\n", n);
        for(int i = 1; i <= n; i ++)
        {
            if(min(t[i], 24 - t[i]) < x) e.add(i, i + n);
            if(min(24 - t[i], t[i]) < x) e.add(i + n, i);
        }
        for(int i = 1; i <= n; i ++)
        {
            for(int j = i + 1; j<= n; j++)
            {
//                if(i == j) continue;
                int t1 = 24 - t[i], t2 = 24 - t[j];
                if(min(abs(t[i] - t[j]), 24 - abs(t[i] - t[j])) < x) e.add(i, j + n), e.add(j, i + n);
                if(min(abs(t[i] - t2), 24 - abs(t[i] - t1)) < x) e.add(i, j), e.add(j + n, i + n);
                if(min(abs(t1 - t[j]), 24 - abs(t1 - t[j])) < x) e.add(i + n, j + n), e.add(j, i);
                if(min(abs(t1 - t2), 24 - abs(t1 - t2)) < x) e.add(i + n, j), e.add(j + n, i);
            }
        }
    }//建图
    void Tarjan(int u)//强连通分量缩点
    {
        dfn[u] = low[u] = ++times; ins[stk[++top] = u] = 1;
        for(int i = e.hd[u], v; i; i = e.e[i].nxt)
        {
            if(!dfn[v = e.e[i].v])
            {
                Tarjan(v);
                low[u] = min(low[u], low[v]);
            }
            else if(ins[v]) low[u] = min(low[u], dfn[v]);
        }
        if(dfn[u] == low[u])
        {
            int v; bel[u] = ++num; ins[u] = 0;
            while(v = stk[top --], v != u) bel[v] = num, ins[v] = 0;
        }
    }
    bool solve(int x)//1:有可行方案 0:无可行方案
    {
        e.init();
        times = num = top = 0;
        for(int i = 1; i <= (n << 1); i ++) bel[i] = dfn[i] = 0;
        build(x);
        for(int i = 1; i <= (n << 1); i ++) if(!dfn[i]) Tarjan(i);
//        for(int i = 1; i <= n; i ++) printf("%d %d\n", bel[i], bel[i + n]);
        for(int i = 1; i <= n; i ++)
            if(bel[i] == bel[i + n]) return 0;//i和i+n在同一连通分量中,不合法
//        for(int i = 1; i <= n; i ++)//输出方案
//        {
//            if(bel[i] < bel[i + n]);//i的联通分量编号小于i+n,不可能由i->i+n,所以选择i
//            else;//选择i+n
//        }
        return 1;//合法
    }
}

int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);

    while(scanf("%d", &n) != EOF)
    {
        for(int i = 1; i <= n; i ++) t[i] = Read();
        int l = 0, r = 12;
        while(l < r)
        {
            int m = (l + r + 1) >> 1;
            if(TwoSat::solve(m)) l = m;
            else r = m - 1;
        }
        printf("%d\n", l);
    }
    return 0;
}


Measured memory_bytes: 256