// Original C++ solution (slower):
#include<cstdio>

#include<cstdlib>

#include<algorithm>

#include<iostream>

#include<queue>

#include<vector>

#include <bitset>

#include<math.h>

#include<map>

#include<set>

#include <climits>

using namespace std;

#define INF 11000000000

#define MOD 1000000007

typedef long long ll;

typedef pair<int,int> P;



int D[20],s[30];

vector<int> v;



void reset(){

    for(int i=0;i<30;i++) s[i]=0;

    for(int i=0;i<(int)v.size();i++){

        s[v[i]]++;

    }

    s[0]++;

    s[24]++;

}





int main(){

    int N,a,ans=0;

    cin>>N;



    for(int i=0;i<N;i++){

        cin>>a;

        D[a]++;

    }



    D[0]++;



    for(int i=0;i<=12;i++){

        if(i==0 && D[i]>=2 || i==12 && D[i]>=2 || D[i]>=3){

            cout<<0<<endl;

            return 0;

        }else if(D[i]==2){

            v.push_back(i); v.push_back(24-i);

            D[i]=0;

        }

    }



    reset();



    for(int bit=0;bit< (1<<13); bit++,reset()){

        for(int i=0;i<13;i++){

            if(D[i]==0) continue;

            if(bit>>i & 1){

                s[24-i]++;

            }else{

                s[i]++;

            }

        }

        int temp=0,ss=100;

        for(int i=1;i<=24;i++){

            if(s[i]){

                ss=min(i-temp,ss);

                temp=i;

            }

        }

        ans=max(ans,ss);

    }

    cout<<ans<<endl;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstdlib>

#include<algorithm>

#include<iostream>

#include<queue>

#include<vector>

#include <bitset>

#include <cmath>

#include <limits>

#include <iostream>

#include<set>

#include<tuple>

using namespace std;

#define INF 11000000000

#define MAX 5100

#define MOD 1000000007

typedef long long ll;

typedef pair<int,int> P;

typedef pair<pair<int,int>,int> p;

typedef pair< pair<int,int>, int> p; 

#define bit(n,k) ((n>>k)&1) /*nのk bit目*/

#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

const double PI = acos(-1);



int C[30];



int main(){

    int N;

    cin>>N;

    C[0]++;

    for(int i=0;i<N;i++){

        int d;

        cin>>d;

        C[d]++;

    }

    for(int i=0;i<23;i++){

        if(C[i]<=1) continue;

        if(C[i]>=3){

            cout<<0<<endl;

            return 0;

        }

        if(i==0 || i>=12){

            cout<<0<<endl;

            return 0;

        }

        C[24-i]++;

    }

    vector<int> V,T;

    for(int i=0;i<=12;i++){

        if(i==0 || i==12){

            if(C[i]) V.push_back(i);

            continue;

        }

        if(C[i] && C[24-i]){

            V.push_back(i);

            V.push_back(24-i);

        }else if(C[i] || C[24-i]){

            T.push_back(i);

        }

    }

    int nV=(int)V.size(),nT=(int)T.size();

    int ans=0;

    for(int S=0;S<(1<<nT);S++){

        vector<int> D;

        for(int i=0;i<nV;i++){

            D.push_back(V[i]);

        }



        for(int i=0;i<nT;i++){

            if(bit(S,i)) D.push_back(24-T[i]);

            else D.push_back(T[i]);

        }

        D.push_back(24);

        int temp=24;

        for(int i=0;i<(int)D.size();i++){

            for(int j=i+1;j<(int)D.size();j++){

                temp=min(temp,   abs(D[i]-D[j])   );

            }

        }



        ans=max(ans,temp);

    }

    cout<<ans<<endl;

}




// Fastest known solution for this problem: