#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;cin>>n;
    vector<int> d(n+1,0),pos(n+1,0);
    for(int i=1;i<=n;i++) cin>>d[i];
    sort(d.begin(),d.end());
    bool f=1;
    for(int i=1;i<=n;i++){
        if(f) pos[i]=-d[i];
        else pos[i]=d[i];
        f = !f;
        //cout<<pos[i]<<endl;
    }
    int res=100;
    for(int i=0;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            int dif=abs(max(pos[i],pos[j])-min(pos[i],pos[j]));
            res = min(res,min(dif,24-dif));
        }
    }
    cout<<res<<endl;
}
