#include <bits/stdc++.h>
using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
int D[55];
bool ex[24];

signed main() {
    cin>>N;
    for(int i=0;i<N;i++)cin>>D[i];
    sort(D,D+N);
    ex[0]=true;
    bool r=true;
    for(int i=0;i<N;i++){
        int idx;
        if(r){
            idx=D[i];
        }else{
            idx=(24-D[i])%24;
        }
        if(ex[idx]){
            cout<<0<<endl;
            return 0;
        }
        ex[idx]=true;
        r=!r;
    }
    int ans=114514,last=0;
    for(int i=1;i<48;i++){
        if(ex[i%24]){
            int x=i%24-min(last,i%24);
            last-=min(last,i%24);
            int d=abs(last-x);
            ans=min({ans,d,24-d});
            last=i%24;
        }
    }
    cout<<ans<<endl;
    return 0;
}