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

signed main()
{
    int N; cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());

    vector<int> b;
    b.push_back(0);
    for(int i=0;i<N;i++){
        if(i%2==0){
            b.push_back(a[i]);
        }else{
            b.push_back(24-a[i]);
        }
    }
    sort(b.begin(),b.end());

    int ans=1e9;
    for(int i=0;i<N;i++){
        ans=min(ans,b[i+1]-b[i]);
    }
    cout<<ans<<endl;
}
