#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repi(i,x,n) for(ll i=x;i<(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    int n,ans;cin>>n;
    vector<int> d(n);
    rep(i,n)cin>>d[i];

    sort(all(d));
    ans=d[0];

    for(int i=0;i < n;i++)
    {
        if(i%2==0){
            d[i]=24-d[i];
        }
    }

    sort(all(d));
    
    

    for(int i=0;i < n-1;i++)
    {
        ans=min(ans,d[i+1]-d[i]);
    }

    cout<<ans<<endl;;


}