stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



#define pb push_back

#define sz(x) ((int)x.size())

#define sqr(x) ((x)*(x))

#define mem(a) memset(a,0,sizeof(a))

#define all(x) x.begin(),x.end()

typedef pair<int, int> pii;

typedef long long ll;

typedef pair<ll, int> pli;



const int mn = 3e5 + 5;

const int maxlog = 19;



int n;

int a[55];

int cnt[15];



int main() {

    //cin.sync_with_stdio(0);

#ifdef trote

    freopen("../1.txt", "r", stdin);

    freopen("../out.txt", "w", stdout);

#endif

    scanf("%d",&n);

    cnt[0]++;

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

        scanf("%d",&a[i]);

        cnt[a[i]]++;

    }

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

        if (cnt[i]>=3) {

            puts("0");

            return 0;

        }

    }

    sort(a+1,a+n+1);

    int ans=0;

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

        vector<int> v;

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

            if (cnt[j]==2){

                v.pb(j);

                v.pb(24-j);

            }

            else if (cnt[j]==1){

                if ((1<<j)&i) v.pb(24-j);

                else v.pb(j);

            }

        }

        sort(all(v));

        v.pb(24);

        int uans=25;

        for(int i=1;i<sz(v);i++){

            uans=min(uans,v[i]-v[i-1]);

        }

        ans=max(ans,uans);

    }

    printf("%d\n",ans);

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.1960586563055697x):
#include <bits/stdc++.h>

using namespace std;

int n, a[55], b[55];

int solve() {

	sort(b+1, b+1+n);

	int ans = 0x3f3f3f3f;

	for (int i = 2; i <= n; i++) ans = min(ans, b[i]-b[i-1]);

	ans = min(ans, b[1]);

	ans = min(ans, 24-b[n]);

	return ans;

}

int main() {

	scanf("%d", &n);

	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);

	sort(a+1, a+1+n);

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

		if (i&1) b[i] = 24-a[i];

		else b[i] = a[i];

	}

	int ans = solve();

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

		if (i&1) b[i] = a[i];

		else b[i] = 24-a[i];

	}

	ans = max(ans, solve());

	cout << ans << endl;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

int main(void){

    int N; cin >> N;

    vector<int> D(N);

    vector<int> Dcount(13);

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

        cin >> D[i];

        Dcount[D[i]]++;

    }

    

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

        if (2 < Dcount[i] || Dcount[0]) {

            cout << 0 << endl;

            return 0;

        }

    }

    

    int ans = -1;    

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

        vector<int> jikoku;

        int bits = i;

        int jisa_min = 13;

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

            if (Dcount[j+1] == 0) continue;

            else if (Dcount[j+1] == 2) {

                jikoku.push_back(j+1);

                jikoku.push_back(24-j-1);

            } else if ((1 << j) & bits) {

                jikoku.push_back(j+1);

            } else {

                jikoku.push_back(24-j-1);

            }

        }

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

            jisa_min = min(min(jikoku[i], 24 - jikoku[i]), jisa_min);

        }

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

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

                jisa_min = min(jisa_min, min(abs(jikoku[i] - jikoku[j]), abs(min(jikoku[i], jikoku[j]) + 24 - max(jikoku[i], jikoku[j]))));

            }

        }

        ans = max(jisa_min, ans);

    }

    cout << ans << endl;

}


// Faster C++ solution for the same problem (measured speedup: 1.7160888891378572x):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define INF 1LL<<62

#define inf 1000000007



ll a[25];

int main() {

	ll n;

	cin>>n;

	a[0]=1;

	for(ll i=0;i<n;i++){

		ll x;

		cin>>x;

		a[x]++;

	}

	ll ans=24;ll now=0;

	bool ch=true;

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

		if(i!=0&&i!=12){

			if(a[i]==2){

				a[i]--;

				a[24-i]++;

			}

			else if(a[i]==1){

				if(ch){

					a[i]--;

					a[24-i]++;

					ch=false;

				}

				else{

					ch=true;

				}

			}

		}

	}

	for(ll i=0;i<24;i++){

		if(a[i]>1){

			cout << 0;

			return 0;

		}

		if(a[i]==1&&i!=0){

			ans=min(ans,i-now);

			now=i;

			continue;

		}

		if(i==23){

			ans=min(ans,24-now);

		}

	}

	cout <<ans;

	// your code goes here

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main()

{

    int N; cin >> N;

    vector<int> C(13);

    C[0] = 1;

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

        int d; cin >> d;

        C[d]++;

    }

    if (any_of(C.begin(), C.end(), [](int c){return c>=3;}) || C[0]==2 || C[12]==2) {

        cout << 0 << endl;

        return 0;

    }

    int ans = 0;

    for (int b = 0; b < (1<<12); b++) {

        vector<int> D;

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

            if (C[i] == 2) {

                D.push_back(i);

                D.push_back(24-i);

            } else if (C[i] == 1) {

                if (b & (1 << i)) {

                    D.push_back(24-i);

                } else {

                    D.push_back(i);

                }

            }

        }

        if (C[12] > 0) D.push_back(12);

        D.push_back(24);

        sort(D.begin(), D.end());

        vector<int> diffs(D.size());

        adjacent_difference(D.begin(), D.end(), diffs.begin());

        int mi = *min_element(diffs.begin(), diffs.end());

        ans = max(ans, mi);

    }



    cout << ans << endl;

}


// Faster C++ solution for the same problem (measured speedup: 1.294499745033702x):
#include <bits/stdc++.h>

using namespace std;



int main()

{

    int N; cin >> N;

    vector<int> C(13);

    C[0] = 1;

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

        int d; cin >> d;

        C[d]++;

    }

    if (any_of(C.begin(), C.end(), [](int c){return c>=3;}) || C[0]==2 || C[12]==2) {

        cout << 0 << endl;

        return 0;

    }

    int ans = 0;

    for (int b = 0; b < (1<<11); b++) {

        vector<int> D;

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

            if (C[i] == 2) {

                D.push_back(i);

                D.push_back(24-i);

            } else if (C[i] == 1) {

                if (b & (1 << (i-1))) {

                    D.push_back(24-i);

                } else {

                    D.push_back(i);

                }

            }

        }

        if (C[12] > 0) D.push_back(12);

        D.push_back(24);

        sort(D.begin(), D.end());

        vector<int> diffs(D.size());

        adjacent_difference(D.begin(), D.end(), diffs.begin());

        int mi = *min_element(diffs.begin(), diffs.end());

        ans = max(ans, mi);

    }



    cout << ans << endl;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;



int main(){

    int n;

    cin >> n;

    vector<int> cnt(13);

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

        int d;

        cin >> d;

        cnt[d]++;

    }

    vector<int> aa;

    aa.push_back(0);

    if(cnt[0] || cnt[12] >= 2){

        cout << 0 << endl;

        return 0;

    }

    if(cnt[12] == 1)

        aa.push_back(12);

    int ans = 0;

    for(int b = 0; b < (1 << 11); b++){

        vector<int> a = aa;

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

            int j = i+1;

            if(cnt[j] == 1){

                if(b >> j & 1)

                    a.push_back(j);

                else

                    a.push_back(24-j);

            } else if(cnt[j] == 2){

                a.push_back(j);

                a.push_back(24-j);

            } else if(cnt[j] >= 3){

                cout << 0 << endl;

                return 0;

            }

        }

        int mn = 24;

        a.push_back(24);

        sort(a.begin(), a.end());

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

            if(mn > a[i+1]-a[i]) mn = a[i+1]-a[i];

        }

        if(ans < mn) ans = mn;

    }

    cout << ans << endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.380537336168393x):
#include <bits/stdc++.h>

using namespace std;

using ll = long long;



int main(){

    int n;

    cin >> n;

    vector<int> cnt(13);

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

        int d;

        cin >> d;

        cnt[d]++;

    }

    vector<int> aa;

    aa.push_back(0);

    if(cnt[0] || cnt[12] >= 2){

        cout << 0 << endl;

        return 0;

    }

    if(cnt[12] == 1)

        aa.push_back(12);

    bool flip = true;

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

        switch(cnt[i]){

            case 0:

                break;

            case 1:

                if(flip) aa.push_back(i);

                else aa.push_back(24-i);

                flip = !flip;

                break;

            case 2:

                aa.push_back(i);

                aa.push_back(24-i);

                break;

            default:

                cout << 0 << endl;

                return 0;

        }

    }

    int mn = 24;

    aa.push_back(24);

    sort(aa.begin(), aa.end());

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

        if(mn > aa[i+1]-aa[i]) mn = aa[i+1]-aa[i];

    }

    cout << mn << endl;

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

using ull = unsigned long long;

using ld = long double;

using pii = pair<int, int>;

using pll = pair<ll, ll>;

using pli = pair<ll, int>;

using pil = pair<int, ll>;

using uint = unsigned int;

template <typename T>

using Graph = vector<vector<T>>;

const int MOD = 1e9 + 7;

const ld PI = acosl(-1);



int main() {

    cin.tie(0);

    ios::sync_with_stdio(false);



    int N;

    cin >> N;



    vector<int> cnt(13);

    cnt[0] = 1;

    bool iszero = false;

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

        int a;

        cin >> a;

        cnt[a]++;

        if (cnt[a] >= 3)

            iszero = true;

    }



    if (iszero) {

        cout << 0 << endl;

        return 0;

    }



    int ans = 0;

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

        vector<int> v;

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

            if (!cnt[j])

                continue;

            if (cnt[j] == 2) {

                v.push_back(j);

                v.push_back(24 - j);

                continue;

            }

            if (i & (1 << j))

                v.push_back(24 - j);

            else

                v.push_back(j);

        }



        int siz = v.size();

        int res = 12;

        for (int j = 0; j < siz; ++j) {

            for (int k = j + 1; k < siz; ++k) {

                int dif = abs(v[j] - v[k]);

                res = min(res, min(dif, 24 - dif));

            }

        }

        ans = max(ans, res);

    }



    cout << ans << endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 2.567693820227854x):
#include <bits/stdc++.h>

using namespace std;



int main() {

    int N;

    cin >> N;

    vector<int> D(N + 1);

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

        cin >> D[i];

    sort(D.begin(), D.end());



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

        if (i & 1)

            D[i] = 24 - D[i];



    int ans = 13;

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

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

            int stmp = abs(D[i] - D[j]);

            ans = min(ans, min(stmp, 24 - stmp));

        }

    }



    cout << ans << endl;



    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define pt(sth) cout << sth << "\n"

#define chmax(a, b) {if(a<b) a=b;}

#define chmin(a, b) {if(a>b) a=b;}

#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

static const ll INF=1e18;

static const ll MAX=101010;

static const ll MOD=1e9+7;



/*

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

   cin >> a[i];

*/





int main(void) {

  ll i, j, k;

  ll N;

  cin >> N;

  ll cnt[15]={};

  

  cnt[0]++; //Takahashi-kun

  for(i=0; i<N; i++) { ll t; cin >> t; cnt[t]++;}

  

  ll f=0;

  for(i=1; i<=11; i++) if(cnt[i]>=3) f=1;

  if(cnt[0]>=2 || cnt[12]>=2) f=1;

  if(f) {pt(0); return 0;}

  

  

  ll ans=0;

  for(ll S=0; S<1<<11; S++) {

    vector<ll> l, r;

    for(i=1; i<=11; i++) {

      if(cnt[i]==1) {

        if(S>>i&1) l.push_back(i);

        else r.push_back(i);

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

        l.push_back(i);

        r.push_back(i);

      }

    }

    if(cnt[12]) l.push_back(12);

    

    ll t=INF;

    ll LS=l.size(), RS=r.size();

    if(LS) chmin(t, l[0]-0);

    for(i=0; i<LS-1; i++) chmin(t, l[i+1]-l[i]);

    

    if(RS) chmin(t, r[0]-0);

    for(i=0; i<RS-1; i++) chmin(t, r[i+1]-r[i]);

    

    if(LS&&RS) chmin(t, 24-(l[LS-1]+r[RS-1]));

    

    chmax(ans, t);

    

  }

  

  

  pt(ans);

  

}




// Faster C++ solution for the same problem (measured speedup: 1.112537369870136x):
#include <bits/stdc++.h>

#define pt(sth) cout << sth << "\n"

#define chmax(a, b) {if(a<b) a=b;}

#define chmin(a, b) {if(a>b) a=b;}

#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

static const ll INF=1e18;

static const ll MAX=101010;

static const ll MOD=1e9+7;



/*

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

   cin >> a[i];

*/





int main(void) {

  ll i, j, k;

  ll N;

  cin >> N;

  ll cnt[15]={};

  

  cnt[0]++; //Takahashi-kun

  for(i=0; i<N; i++) { ll t; cin >> t; cnt[t]++;}

  

  ll f=0;

  for(i=1; i<=11; i++) if(cnt[i]>=3) f=1;

  if(cnt[0]>=2 || cnt[12]>=2) f=1;

  if(f) {pt(0); return 0;}

  

  

  ll ans=0;

  for(ll S=0; S<1<<10; S++) {

    vector<ll> v; v.push_back(0);

    for(i=1; i<=11; i++) {

      if(cnt[i]==1) {

        if(S>>(i-1)&1) v.push_back(i);

        else v.push_back(24-i);

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

        v.push_back(i);

        v.push_back(24-i);

      }

    }

    if(cnt[12]) v.push_back(12);

    sort(v.begin(), v.end());

    

    

    ll t=INF;

    ll L=v.size();

    for(i=0; i<L-1; i++) chmin(t, v[i+1]-v[i]);

    chmin(t, 24-v[L-1]);

    

    

    chmax(ans, t);

  }

  

  

  pt(ans);

  

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define pt(sth) cout << sth << "\n"

#define chmax(a, b) {if(a<b) a=b;}

#define chmin(a, b) {if(a>b) a=b;}

#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

static const ll INF=1e18;

static const ll MAX=101010;

static const ll MOD=1e9+7;



/*

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

   cin >> a[i];

*/





int main(void) {

  ll i, j, k;

  ll N;

  cin >> N;

  ll cnt[15]={};

  

  cnt[0]++; //Takahashi-kun

  for(i=0; i<N; i++) { ll t; cin >> t; cnt[t]++;}

  

  ll f=0;

  for(i=1; i<=11; i++) if(cnt[i]>=3) f=1;

  if(cnt[0]>=2 || cnt[12]>=2) f=1;

  if(f) {pt(0); return 0;}

  

  

  ll ans=0;

  for(ll S=0; S<1<<11; S++) {

    vector<ll> l, r;

    for(i=1; i<=11; i++) {

      if(cnt[i]==1) {

        if(S>>i&1) l.push_back(i);

        else r.push_back(i);

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

        l.push_back(i);

        r.push_back(i);

      }

    }

    if(cnt[12]) l.push_back(12);

    

    ll t=INF;

    ll LS=l.size(), RS=r.size();

    if(LS) chmin(t, l[0]-0);

    for(i=0; i<LS-1; i++) chmin(t, l[i+1]-l[i]);

    

    if(RS) chmin(t, r[0]-0);

    for(i=0; i<RS-1; i++) chmin(t, r[i+1]-r[i]);

    

    if(LS&&RS) chmin(t, 24-(l[LS-1]+r[RS-1]));

    

    chmax(ans, t);

    

  }

  

  

  pt(ans);

  

}




// Faster C++ solution for the same problem (measured speedup: 1.302559222770143x):
#include <bits/stdc++.h>

#define pt(sth) cout << sth << "\n"

#define chmax(a, b) {if(a<b) a=b;}

#define chmin(a, b) {if(a>b) a=b;}

#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

static const ll INF=1e18;

static const ll MAX=101010;

static const ll MOD=1e9+7;



/*

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

   cin >> a[i];

*/





int main(void) {

  ll i, j, k;

  ll N;

  cin >> N;

  ll d[55];

  

  for(i=0; i<N; i++) cin >> d[i];

  sort(d, d+N);

  

  

  vector<ll> v; v.push_back(0);

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

    if(i&1) v.push_back(d[i]);

    else v.push_back(24-d[i]);

  }

  v.push_back(24);

  sort(v.begin(), v.end());

  

  ll ans=INF;

  for(i=0; i<(ll)v.size()-1; i++) chmin(ans, v[i+1]-v[i]);

  

  pt(ans);

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define pt(sth) cout << sth << "\n"

#define chmax(a, b) {if(a<b) a=b;}

#define chmin(a, b) {if(a>b) a=b;}

#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

static const ll INF=1e18;

static const ll MAX=101010;

static const ll MOD=1e9+7;



/*

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

   cin >> a[i];

*/





int main(void) {

  ll i, j, k;

  ll N;

  cin >> N;

  ll cnt[15]={};

  

  cnt[0]++; //Takahashi-kun

  for(i=0; i<N; i++) { ll t; cin >> t; cnt[t]++;}

  

  ll f=0;

  for(i=1; i<=11; i++) if(cnt[i]>=3) f=1;

  if(cnt[0]>=2 || cnt[12]>=2) f=1;

  if(f) {pt(0); return 0;}

  

  

  ll ans=0;

  for(ll S=0; S<1<<10; S++) {

    vector<ll> v; v.push_back(0);

    for(i=1; i<=11; i++) {

      if(cnt[i]==1) {

        if(S>>(i-1)&1) v.push_back(i);

        else v.push_back(24-i);

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

        v.push_back(i);

        v.push_back(24-i);

      }

    }

    if(cnt[12]) v.push_back(12);

    sort(v.begin(), v.end());

    

    

    ll t=INF;

    ll L=v.size();

    for(i=0; i<L-1; i++) chmin(t, v[i+1]-v[i]);

    chmin(t, 24-v[L-1]);

    

    

    chmax(ans, t);

  }

  

  

  pt(ans);

  

}




// Faster C++ solution for the same problem (measured speedup: 1.1708004225711428x):
#include <bits/stdc++.h>

#define pt(sth) cout << sth << "\n"

#define chmax(a, b) {if(a<b) a=b;}

#define chmin(a, b) {if(a>b) a=b;}

#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

static const ll INF=1e18;

static const ll MAX=101010;

static const ll MOD=1e9+7;



/*

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

   cin >> a[i];

*/





int main(void) {

  ll i, j, k;

  ll N;

  cin >> N;

  ll d[55];

  

  for(i=0; i<N; i++) cin >> d[i];

  sort(d, d+N);

  

  

  vector<ll> v; v.push_back(0);

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

    if(i&1) v.push_back(d[i]);

    else v.push_back(24-d[i]);

  }

  v.push_back(24);

  sort(v.begin(), v.end());

  

  ll ans=INF;

  for(i=0; i<(ll)v.size()-1; i++) chmin(ans, v[i+1]-v[i]);

  

  pt(ans);

}
// Slower C++ solution:
#include <algorithm>

#include <cstdio>

#include <iostream>

using namespace std;

 

const int N = 51;

int d[N];

int p[N];

int foo[N];

int n;

int res;

 

void backtrack(int i) {

    if (i == n) {

        copy(foo, foo + n, p);

        sort(p, p + n);

        int s = 24;

        for (int i = 0, j = n - 1; i < n; j = i++) {

            s = min(s, min(abs(p[i] - p[j]), 24 - abs(p[i] - p[j])));

        }

        res = max(res, s);

    } else {

        for (int t = -1; t <= 1; t += 2) {

            foo[i] = d[i] * t;

            backtrack(i + 1);

            if (d[i] == 12 || d[i] == 0) break;

        }

    }

}

 

int main() {

    scanf("%d", &n);

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

		scanf("%d",&d[i]);

	}

    foo[1] = d[1];

    ++ n;

    if (n > 24) {

        printf("0");

        return 0;

    }

    

    backtrack(2);

    printf("%d\n",res);	



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.164043555238724x):
#include<cstdio>

#include<cstring>

#include<algorithm>

int a[60];



int main()

{

	int n;scanf("%d",&n);n++;

	for(int i=2;i<=n;i++)

		scanf("%d",&a[i]);

	std::sort(a+1,a+n+1);

	for(int i=1;i<=n;i++)

	{

		if(i&1)

			a[i]=24-a[i];

		if(a[i]==24)

			a[i]=0;

	}

	std::sort(a+1,a+n+1);

	int mx=2147483647;

	for(int i=2;i<=n;i++)

		mx=std::min(mx,a[i]-a[i-1]);

	printf("%d\n",mx);

	return 0;

}
// Slower C++ solution:
#include <algorithm>

#include <cstdio>

#include <iostream>

using namespace std;

 

const int N = 51;

int d[N];

int p[N];

int foo[N];

int n;

int res;

 

void backtrack(int i) {

    if (i == n) {

        copy(foo, foo + n, p);

        sort(p, p + n);

        int s = 24;

        for (int i = 0, j = n - 1; i < n; j = i++) {

            s = min(s, min(abs(p[i] - p[j]), 24 - abs(p[i] - p[j])));

        }

        res = max(res, s);

    } else {

        for (int t = -1; t <= 1; t += 2) {

            foo[i] = d[i] * t;

            backtrack(i + 1);

            if (d[i] == 12 || d[i] == 0) break;

        }

    }

}

 

int main() {

    scanf("%d", &n);

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

		scanf("%d",&d[i]);

	}

    foo[1] = d[1];

    ++ n;

    if (n > 24) {

        printf("0");

        return 0;

    }

    

    backtrack(2);

    printf("%d\n",res);	



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.145657509002885x):
#include<stdio.h>

#include<algorithm>



using namespace std;



int dp[55][55][55];

int ar[55];

int n;



int serc(int x, int l, int r) {

  if (x == n) {

    return 1000000;

  }

  int &ret = dp[x][l][r];

  if (ret != -1) {

    return ret;

  }

  ret = 0;



  // ambil ke kanan

  ret = max(ret, min(serc(x + 1, l, x), min(ar[x] - ar[r], 24 - ar[l] - ar[x])));



  // ambil ke kiri

  ret = max(ret, min(serc(x + 1, x, r), min(ar[x] - ar[l], 24 - ar[r] - ar[x])));

  return ret;

}



int main() {

  scanf("%d", &n);

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

    scanf("%d", &ar[i]);

    for (int j = 0; j <= n; j++) {

      for (int k = 0; k <= n; k++) {

        dp[i][j][k] = -1;

      }

    }

  }

  n++;

  sort(ar, ar + n);

  printf("%d\n", min(max(serc(2, 0, 1), serc(2, 1, 0)), ar[1] - ar[0]));

  return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define GLX glx ak!!

#define ZZH zzh ak!!

#define LYH lyh ak!!

#define XRY xry ak!!

#define ZJH zjh ak!!

#define HP hp ak!!

#define WXH wxh ak!!

#define JIRY jiry good teacher

#define DYH dyh good teacher

#define ll long long

using namespace std;

int n,ans,x,f[110];

bool vis[110];

inline void dfs(int x){

    if(x>12){

        int ret=24;

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

            for(int j=i+1;j<=23;j++)

                if(vis[i]&&vis[j]) ret=min(ret,min(j-i,24-j+i));

        ans=max(ans,ret);

        return ;

    }

    if(f[x]==2){

		vis[x]=vis[24-x]=1;

		dfs(x+1);

		return;

	}

	if(f[x]){

        vis[x]=1;

		dfs(x+1);

		vis[x]=0;

        if(x){

        	vis[24-x]=1;

			dfs(x+1);

			vis[24-x]=0;

    	}

		return ;

	}

    dfs(x+1);

	return;

}

int main(){

    scanf("%d",&n);

    f[0]=1;

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

		scanf("%d",&x);

		f[x]++;

	}

	if(f[12]>1||f[0]>1){puts("0");return 0;}

    for(int i=1;i<=12;i++) if(f[i]>2){puts("0");return 0;}

    dfs(0);

    printf("%d",ans);

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.167051915423827x):
#include<stdio.h>

#include<algorithm>



using namespace std;



int dp[55][55][55];

int ar[55];

int n;



int serc(int x, int l, int r) {

  if (x == n) {

    return 1000000;

  }

  int &ret = dp[x][l][r];

  if (ret != -1) {

    return ret;

  }

  ret = 0;



  // ambil ke kanan

  ret = max(ret, min(serc(x + 1, l, x), min(ar[x] - ar[r], 24 - ar[l] - ar[x])));



  // ambil ke kiri

  ret = max(ret, min(serc(x + 1, x, r), min(ar[x] - ar[l], 24 - ar[r] - ar[x])));

  return ret;

}



int main() {

  scanf("%d", &n);

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

    scanf("%d", &ar[i]);

    for (int j = 0; j <= n; j++) {

      for (int k = 0; k <= n; k++) {

        dp[i][j][k] = -1;

      }

    }

  }

  n++;

  sort(ar, ar + n);

  printf("%d\n", min(max(serc(2, 0, 1), serc(2, 1, 0)), ar[1] - ar[0]));

  return 0;

}