stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

using namespace std;

typedef long long int ll;

ll max(ll a,ll b)

{

	return a>b?a:b;

}

int main()

{

	ios;

	ll a,b,c,d,ed;

	cin>>a>>b>>c>>d;

	ed=a*c;

	ed=max(ed,a*d);

	ed=max(ed,b*d);

	ed=max(ed,b*c);

	cout<<ed<<'\n';

}

// Optimized solution to the same problem (faster):
#include<stdio.h>



int main()

{

    long long int i, a, b, c, d,ans;

    long long int e,f,j,z;

    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);



    z=a*c;

    e=a*d;

    f=b*c;

    j=b*d;

    //i = z;

   if(z>e&&z>f&&z>j)ans=z;

   else if(e>z&&e>f&&e>j)ans=e;

   else if(f>e&&f>z&&f>j)ans=f;

   else

    ans=j;

   printf("%lld",ans);



   return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

#include<math.h>

using namespace std;

typedef long long ll;



ll a,b,c,d,ans;

int main()

{

    cin>>a>>b>>c>>d;

    ans=max(max(a,b)*max(c,d),min(a,b)*min(c,d));

    ans=max(ans,max(a,b)*min(c,d));

    ans=max(ans,min(a,b)*max(c,d));

    cout<<ans<<endl;

    return 0;

}

////刷题！！！！！！！！！！！！！！！！


// Optimized solution to the same problem (faster):
#include<stdio.h>



int main()

{

    long long int i, a, b, c, d,ans;

    long long int e,f,j,z;

    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);



    z=a*c;

    e=a*d;

    f=b*c;

    j=b*d;

    //i = z;

   if(z>e&&z>f&&z>j)ans=z;

   else if(e>z&&e>f&&e>j)ans=e;

   else if(f>e&&f>z&&f>j)ans=f;

   else

    ans=j;

   printf("%lld",ans);



   return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main()

{

    ll a,b,c,d,x,y;

    scanf("%lld %lld %lld %lld", &a,&b,&c,&d);

    x = max(max(a*c,a*d), max(b*c,b*d));

    printf("%lld\n", x);

    return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>



int main()

{

    long long int i, a, b, c, d,ans;

    long long int e,f,j,z;

    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);



    z=a*c;

    e=a*d;

    f=b*c;

    j=b*d;

    //i = z;

   if(z>e&&z>f&&z>j)ans=z;

   else if(e>z&&e>f&&e>j)ans=e;

   else if(f>e&&f>z&&f>j)ans=f;

   else

    ans=j;

   printf("%lld",ans);



   return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;



int main()

{

    long long int a,b,c,d;

    cin>> a >> b >> c >>d;

    long long int ans[4];

    ans[0]=a*c;

    ans[1]=a*d;

    ans[2]=b*c;

    ans[3]=b*d;

    sort(ans,ans+4);

    cout << ans[3];

    return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>



int main()

{

    long long int i, a, b, c, d,ans;

    long long int e,f,j,z;

    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);



    z=a*c;

    e=a*d;

    f=b*c;

    j=b*d;

    //i = z;

   if(z>e&&z>f&&z>j)ans=z;

   else if(e>z&&e>f&&e>j)ans=e;

   else if(f>e&&f>z&&f>j)ans=f;

   else

    ans=j;

   printf("%lld",ans);



   return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
/*

* @Author: Kabid

* @Date:   {{create_time}}

* @Last Modified by:   Kabid

* @Last Modified time: 2020-09-19 12:16:37

*/

#include<bits/stdc++.h>

using namespace std;

#define ll long long

#define  in(x) scanf("%d",&x);

#define out(x) printf("%d",x);

#define  ins(x)  scanf("%s",x);

#define outs(x) printf("%s",x);

#define lin puts("");

#define _ putchar(' ');



int t;       //test cases

ll i, j;	 //iterators

ll n, k , p, q,  d, m, c, c1, c2, d1; //variables;

ll mx = LLONG_MIN, mn = LLONG_MAX;		// max min

string s, s1, s2;		// string

ll a [1000001], b [200001] , mox [200001];	// array

map <int, int > mp;

vector <vector<ll>> vc;

vector <ll> v;

set <ll> st;

bool r;



int main() {

	ios_base::sync_with_stdio(0);

	cin.tie(0);

	//cin >> t; q=t;

	t = 1;

	while (t--) {





		cin >> p >> q >> d >> m;

		mx = max(mx, p * d);

		mx = max(mx, p * m);

		mx = max(mx, q * d);

		mx = max(mx, q * m);

		cout << mx << endl;

	}





	return 0;



}


// Optimized solution to the same problem (faster):
#include<stdio.h>



int main()

{

    long long int i, a, b, c, d,ans;

    long long int e,f,j,z;

    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);



    z=a*c;

    e=a*d;

    f=b*c;

    j=b*d;

    //i = z;

   if(z>e&&z>f&&z>j)ans=z;

   else if(e>z&&e>f&&e>j)ans=e;

   else if(f>e&&f>z&&f>j)ans=f;

   else

    ans=j;

   printf("%lld",ans);



   return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main(){





ll a,b,c,d,ans,t;

while(cin>>a>>b>>c>>d){

ans=a*c;

t=a*d;

ans=max(ans,t);

t=b*c;

ans=max(t,ans);

t=b*d;

ans=max(ans,t);

cout<<ans<<endl;





}











return 0;}




// Optimized solution to the same problem (faster):
#include<stdio.h>



int main()

{

    long long int i, a, b, c, d,ans;

    long long int e,f,j,z;

    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);



    z=a*c;

    e=a*d;

    f=b*c;

    j=b*d;

    //i = z;

   if(z>e&&z>f&&z>j)ans=z;

   else if(e>z&&e>f&&e>j)ans=e;

   else if(f>e&&f>z&&f>j)ans=f;

   else

    ans=j;

   printf("%lld",ans);



   return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int main()

{

	long long a, b, c, d;

	cin >> a >> b >> c >> d;

    long long x, y, sol;

	((a*c) > (a*d)) ? x = (a*c) : x = (a*d);

	((b*c) > (b*d)) ? y = (b*c) : y = (b*d);

	(x>y) ? sol = x : sol = y;

	cout << sol << endl;

	return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>



int main()

{

    long long int i, a, b, c, d,ans;

    long long int e,f,j,z;

    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);



    z=a*c;

    e=a*d;

    f=b*c;

    j=b*d;

    //i = z;

   if(z>e&&z>f&&z>j)ans=z;

   else if(e>z&&e>f&&e>j)ans=e;

   else if(f>e&&f>z&&f>j)ans=f;

   else

    ans=j;

   printf("%lld",ans);



   return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;





int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);



    long long a,b,c,d;

    cin>>a>>b>>c>>d;



    vector<long long> arr;

    arr.push_back(a*c);

    arr.push_back(a*d);

    arr.push_back(b*c);

    arr.push_back(b*d);

    



    cout<<*max_element(arr.begin(),arr.end());

    



    return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>



int main()

{

    long long int i, a, b, c, d,ans;

    long long int e,f,j,z;

    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);



    z=a*c;

    e=a*d;

    f=b*c;

    j=b*d;

    //i = z;

   if(z>e&&z>f&&z>j)ans=z;

   else if(e>z&&e>f&&e>j)ans=e;

   else if(f>e&&f>z&&f>j)ans=f;

   else

    ans=j;

   printf("%lld",ans);



   return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
/**



         Hlw sir



**/



#include<iostream>



using namespace std;



int main()

{

	long long a, b, c, d;

	long long prdct[4];

	cin >> a >> b >> c >> d;

	prdct[0] = a*c;

	prdct[1] = a*d;

	prdct[2] = b*c;

	prdct[3] = b*d;

	long long max = prdct[0];

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

	{

		if(prdct[i] > max)

		{

			max = prdct[i];

		}

	}

	cout << max << endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>



int main()

{

    long long int i, a, b, c, d,ans;

    long long int e,f,j,z;

    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);



    z=a*c;

    e=a*d;

    f=b*c;

    j=b*d;

    //i = z;

   if(z>e&&z>f&&z>j)ans=z;

   else if(e>z&&e>f&&e>j)ans=e;

   else if(f>e&&f>z&&f>j)ans=f;

   else

    ans=j;

   printf("%lld",ans);



   return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



#define pb push_back

#define pp pop_back

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



const int inf = (int)1e9 + 7;



int d[55];

int ans, n;



void go (int in, vector < int > vec) {

    if (in == n + 1) {

        int dif = inf;

        sort(all(vec));

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

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

                int q1 = vec[i];

                int q2 = vec[j];

                q2 -= q1;

                q1 = 0;

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

            }

        }

        ans = max(ans, dif);

        if (clock() > CLOCKS_PER_SEC * 1.5) {

            cout << ans;

            exit(0);

        }

        return ;

    }

    vec.pb(d[in]);

    go(in + 1, vec);

    vec.pp();



    vec.pb(24 - d[in]);

    go(in + 1, vec);

}



main() {

    scanf ("%d", &n);

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

        scanf ("%d", d + i);

    }

    vector < int > vec;

    vec.pb(0);

    go(1, vec);

    cout << ans;

}


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

#include <algorithm> 

using namespace std;

int n,ans=24,a[24];

int main(){

	scanf("%d",&n);

	if (n>=24){puts("0");return 0;}

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

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

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

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

		if (a[i]==24) a[i]=0; 

	}

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

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

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

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int c[22];



int main()

{

    int n,x;

    scanf("%d",&n);

    ++c[0];

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

        scanf("%d",&x);

        ++c[x];

    }

    if (*max_element(c,c+13)>2) {

        puts("0");

    } else if (c[0]>1) {

        puts("0");

    } else {

        vector<int> fix;

        vector<int> tmp;

        fix.push_back(0);

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

            if (c[i]==2) {

                fix.push_back(i);

                fix.push_back(24-i);

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

                tmp.push_back(i);

            }

        }

        int m=tmp.size();

        int lim=1<<m;

        int ans=0;

        for (int st=0;st<lim;st++) {

            vector<int> res(fix);

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

                if (st>>i&1) {

                    res.push_back(24-tmp[i]);

                } else {

                    res.push_back(tmp[i]);

                }

            }

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

            res.push_back(24);

            int now=1111;

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

                now=min(now,res[i]-res[i-1]);

            }

            ans=max(ans,now);

        }

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

    }

    return 0;

}


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

#include <algorithm> 

using namespace std;

int n,ans=24,a[24];

int main(){

	scanf("%d",&n);

	if (n>=24){puts("0");return 0;}

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

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

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

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

		if (a[i]==24) a[i]=0; 

	}

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

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

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

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#define N 50

using namespace std;

int ans,n,a[N|1],cnt[N|1],tot,pick[N|1],k,num[N|1],tmp[N|1];

void dfs(int d) {

	if(d>k) {

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

			tmp[i]=pick[i];

		int mn=abs(tmp[1]-tmp[2]);

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

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

				mn=min(mn,min(abs(tmp[i]-tmp[j]),24-abs(tmp[i]-tmp[j])));

		ans=max(ans,mn);

		return;

	}

	pick[++tot]=num[d];

	dfs(d+1);

	if(num[d])

		pick[tot]=24-num[d];

	dfs(d+1);

	tot--;

}

int main() {

	scanf("%d",&n);

	cnt[0]=1;

	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||(cnt[i]==2&&(i==0||i==12))) {

			puts("0");

			return 0;

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

			pick[++tot]=i;

			pick[++tot]=24-i;

		} else if(cnt[i]==1&&(i==0||i==12)) {

			pick[++tot]=i;

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

			num[++k]=i;

		}

	}

	dfs(1);

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

	return 0;

}

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

#include <algorithm> 

using namespace std;

int n,ans=24,a[24];

int main(){

	scanf("%d",&n);

	if (n>=24){puts("0");return 0;}

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

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

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

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

		if (a[i]==24) a[i]=0; 

	}

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

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

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

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

int n,u,t[13],ans=1000000000,s[25],e;

void find(int x,int y){

	if(x==13){

		ans=max(ans,y);

		return;

	}

	if(t[x]==1){

		int d=y;

		for(int i=24-x-1;i>0;i--){

			if(s[i]==1){

				d=min(d,24-x-i);

				break;

			}

		}

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

			if(s[i]==1){

				d=min(d,i+x-24);

				break;

			}

		}

		s[24-x]=1;

		find(x+1,d);

		s[24-x]=0;

		d=y;

		for(int i=x-1;i>0;i--){

			if(s[i]==1){

				d=min(d,x-i);

				break;

			}

		}

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

			if(s[i]==1){

				d=min(d,i-x);

				break;

			}

		}

		s[x]=1;

		find(x+1,d);

		d=y;

		s[x]=0;

	}

	else find(x+1,y);

	return;

}

int main(){

	scanf("%d",&n);

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

		scanf("%d",&u);

		t[u]++;

		ans=min(ans,u);

	}

	if(t[0]==1){

		printf("0");

		return 0;

	}

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

		if(t[i]==2)ans=min(ans,24-i-i),s[i]=1,s[24-i]=1;

		else if(t[i]>=3)ans=0;

	}

	if(ans==0){

		printf("0");

		return 0;

	}

	else{

		e=ans;

		ans=0;

		find(1,e);

	}

	printf("%d",ans);

	return 0;

}

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

#include <algorithm> 

using namespace std;

int n,ans=24,a[24];

int main(){

	scanf("%d",&n);

	if (n>=24){puts("0");return 0;}

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

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

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

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

		if (a[i]==24) a[i]=0; 

	}

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

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

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

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

} 

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem: