#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#include<limits>
#include<bitset>
#include<ctype.h>
#include<set>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007LL;
const ll INF=1000000000;
const int MAX=100001;
struct edge{int to,cost;};
typedef pair<int,int> P;
int d[51];
int n;
int main(){
    cin>>n;
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>d[i];
    }
    sort(d,d+n);
    int a[51]={};
    int b[51];
    bool f=true;
    for(int i=0;i<n;i++){
        if(f){
            a[i]=d[i];
            f=false;
        }else{
            a[i]=24-d[i];
            f=true;
        }
        b[i]=a[i];
    }
    a[n]=0;
    int s=INF;
    sort(a,a+n+1);
    for(int j=1;j<=n;j++){
        s=min(s,min(abs(a[j]-a[j-1]),24-abs(a[j]-a[j-1])));
    }
    s=min(s,min(abs(a[n]-a[0]),24-abs(a[n]-a[0])));
    for(int j=0;j<n;j++){
        a[j]=b[j];
    }
    ans=s;
    cout<<ans<<endl;
    getchar();
    getchar();
}

                           
