#include <bits/stdc++.h>
#define LL long long
using namespace std;
 
vector<int> bit, val;
int cnt[30];
 
int main()
{
    int n;
    scanf("%d", &n);
    val.push_back(0);
 
    for(int i = 0; i < n; i ++) {
        int x;
        scanf("%d", &x);
 
        if(x < 12)
            cnt[x] ++;
        else
            cnt[24 - x] ++;
 
    }
 
    for(int i = 0; i <= 12; i++) {
        if(cnt[i] > 2)
            return !printf("0");
        else if(cnt[i] == 2)
            val.push_back(i), val.push_back(24 - i);
        else if (cnt[i] == 1)
            bit.push_back(i);
    }
 
 
    int ans = -1;
 
    for(int i = 0; i < 1 << bit.size(); i++) {
        int cur = 100;
        for(int j = 0; j < bit.size(); j++) {
            if(i & (1 << j))
                val.push_back(bit[j]);
            else
                val.push_back(24 - bit[j]);
        }
        for(int j = 0; j < val.size(); j++) {
            for(int k = j + 1; k < val.size(); k++) {
                int t = val[j], tt = val[k];
                if(t > tt)
                    swap(t, tt);
                tt -= t;
                cur = min(cur, min(tt, 24 - tt));
            }
        }
        for(int j = 0; j < bit.size(); j++)
            val.pop_back();
        ans = max(ans, cur);
    }
    printf("%d\n", ans);
    return 0;
}