stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
//Mahir Ratanpara (DA-IICT)

#include<bits/stdc++.h>

using namespace std;

#define Ff(i,a,n) for(i=a;i<n;i++)

#define Fr(i,a,n) for(i=a;i>n;i--)

#define ll long long

#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

#define pb push_back

#define ff first

#define ss second

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

#define clr(x) memset(x, 0, sizeof(x))

#define sortall(x) sort(all(x))

#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)

typedef pair<ll, ll>	pa;

typedef vector<ll>		vc;

typedef vector<pa>		vp;

typedef vector<vc>		vvc;

int mpow(int base, int exp); 

void ipgraph(ll n,ll m);

void dfs(int u, int par);

const int mod = 1000000007;

const int N = 3e5, M = N;

//=======================



vc g[N];



int main() {

    FAST;

    ll t, i, l,j, k, p, q, r, x, y, u, v, n, m;

    n=4;

    vc a(n);

    Ff(i,0,n)

    cin>>a[i];



    ll maxi=-1e18;

    Ff(i,0,2)

    {

      Ff(j,2,n)

      {

        maxi=max(maxi,a[i]*a[j]);

      }

    }

    cout<<maxi<<"\n";

    return 0;

}



int mpow(int base, int exp) {

  base %= mod;

  int result = 1;

  while (exp > 0) {

    if (exp & 1) result = ((ll)result * base) % mod;

    base = ((ll)base * base) % mod;

    exp >>= 1;

  }

  return result;

}



void ipgraph(ll n, ll m){

	int i, u, v;

	while(m--){

		cin>>u>>v;

		g[u-1].pb(v-1);

		g[v-1].pb(u-1);

	}

}



void dfs(int u, int par){

	for(int v:g[u]){

		if (v == par) continue;

		dfs(v, u);

	}

}

// Faster C++ solution for the same problem (measured speedup: 9.328218091769733x):
/* *Your Love Makes me STRONG,

   You'r Hate Makes Me UNSTOPABBLE.*

 

  *HOPE is a good thing,Maybe The BEST of Things.

   And No Good Things Ever Dies.*

  

  *Keep calm,Be patient And Chase Your DREAM*



*/





#include<bits/stdc++.h>

#define ll long long

#define pb push_back

#define MN7 ios::sync_with_stdio(0);cin.tie(nullptr);

using namespace std;

ll t,n,i,j,k,a,b,c,d,p,q,r,x,y,z,m,cnt,flag,ans;

string s;

void nahid()

{

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

 x=a*c;y=a*d;z=b*c;p=b*d;

 q=max(x,y);

 r=max(z,p);

 ans=max(q,r);

cout<<ans<<endl;





}

int main()

{ MN7// cin>>t;while(t--)

  nahid();

}
// Slower C++ solution:
//Mahir Ratanpara (DA-IICT)

#include<bits/stdc++.h>

using namespace std;

#define Ff(i,a,n) for(i=a;i<n;i++)

#define Fr(i,a,n) for(i=a;i>n;i--)

#define ll long long

#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

#define pb push_back

#define ff first

#define ss second

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

#define clr(x) memset(x, 0, sizeof(x))

#define sortall(x) sort(all(x))

#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)

typedef pair<ll, ll>	pa;

typedef vector<ll>		vc;

typedef vector<pa>		vp;

typedef vector<vc>		vvc;

int mpow(int base, int exp); 

void ipgraph(ll n,ll m);

void dfs(int u, int par);

const int mod = 1000000007;

const int N = 3e5, M = N;

//=======================



vc g[N];



int main() {

    FAST;

    ll t, i, l,j, k, p, q, r, x, y, u, v, n, m;

    n=4;

    vc a(n);

    Ff(i,0,n)

    cin>>a[i];



    ll maxi=-1e18;

    Ff(i,0,2)

    {

      Ff(j,2,n)

      {

        maxi=max(maxi,a[i]*a[j]);

      }

    }

    cout<<maxi<<"\n";

    return 0;

}



int mpow(int base, int exp) {

  base %= mod;

  int result = 1;

  while (exp > 0) {

    if (exp & 1) result = ((ll)result * base) % mod;

    base = ((ll)base * base) % mod;

    exp >>= 1;

  }

  return result;

}



void ipgraph(ll n, ll m){

	int i, u, v;

	while(m--){

		cin>>u>>v;

		g[u-1].pb(v-1);

		g[v-1].pb(u-1);

	}

}



void dfs(int u, int par){

	for(int v:g[u]){

		if (v == par) continue;

		dfs(v, u);

	}

}

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



using namespace std;



typedef long long ll;



int main()

{

    ll a,b,c,d;

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

    ll ans;

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

    cout << ans << endl;

}
// Slower C++ solution:
//Mahir Ratanpara (DA-IICT)

#include<bits/stdc++.h>

using namespace std;

#define Ff(i,a,n) for(i=a;i<n;i++)

#define Fr(i,a,n) for(i=a;i>n;i--)

#define ll long long

#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

#define pb push_back

#define ff first

#define ss second

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

#define clr(x) memset(x, 0, sizeof(x))

#define sortall(x) sort(all(x))

#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)

typedef pair<ll, ll>	pa;

typedef vector<ll>		vc;

typedef vector<pa>		vp;

typedef vector<vc>		vvc;

int mpow(int base, int exp); 

void ipgraph(ll n,ll m);

void dfs(int u, int par);

const int mod = 1000000007;

const int N = 3e5, M = N;

//=======================



vc g[N];



int main() {

    FAST;

    ll t, i, l,j, k, p, q, r, x, y, u, v, n, m;

    n=4;

    vc a(n);

    Ff(i,0,n)

    cin>>a[i];



    ll maxi=-1e18;

    Ff(i,0,2)

    {

      Ff(j,2,n)

      {

        maxi=max(maxi,a[i]*a[j]);

      }

    }

    cout<<maxi<<"\n";

    return 0;

}



int mpow(int base, int exp) {

  base %= mod;

  int result = 1;

  while (exp > 0) {

    if (exp & 1) result = ((ll)result * base) % mod;

    base = ((ll)base * base) % mod;

    exp >>= 1;

  }

  return result;

}



void ipgraph(ll n, ll m){

	int i, u, v;

	while(m--){

		cin>>u>>v;

		g[u-1].pb(v-1);

		g[v-1].pb(u-1);

	}

}



void dfs(int u, int par){

	for(int v:g[u]){

		if (v == par) continue;

		dfs(v, u);

	}

}

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

using namespace std;

long long arr[4];

int main()

{

    long long a,b,c,d;

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

    arr[0]=a*c;

    arr[1]=a*d;

    arr[2]=b*c;

    arr[3]=b*d;

    sort(arr,arr+4);

    cout<<arr[3]<<endl;









    return 0;

}
// Slower C++ solution:
//Mahir Ratanpara (DA-IICT)

#include<bits/stdc++.h>

using namespace std;

#define Ff(i,a,n) for(i=a;i<n;i++)

#define Fr(i,a,n) for(i=a;i>n;i--)

#define ll long long

#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

#define pb push_back

#define ff first

#define ss second

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

#define clr(x) memset(x, 0, sizeof(x))

#define sortall(x) sort(all(x))

#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)

typedef pair<ll, ll>	pa;

typedef vector<ll>		vc;

typedef vector<pa>		vp;

typedef vector<vc>		vvc;

int mpow(int base, int exp); 

void ipgraph(ll n,ll m);

void dfs(int u, int par);

const int mod = 1000000007;

const int N = 3e5, M = N;

//=======================



vc g[N];



int main() {

    FAST;

    ll t, i, l,j, k, p, q, r, x, y, u, v, n, m;

    n=4;

    vc a(n);

    Ff(i,0,n)

    cin>>a[i];



    ll maxi=-1e18;

    Ff(i,0,2)

    {

      Ff(j,2,n)

      {

        maxi=max(maxi,a[i]*a[j]);

      }

    }

    cout<<maxi<<"\n";

    return 0;

}



int mpow(int base, int exp) {

  base %= mod;

  int result = 1;

  while (exp > 0) {

    if (exp & 1) result = ((ll)result * base) % mod;

    base = ((ll)base * base) % mod;

    exp >>= 1;

  }

  return result;

}



void ipgraph(ll n, ll m){

	int i, u, v;

	while(m--){

		cin>>u>>v;

		g[u-1].pb(v-1);

		g[v-1].pb(u-1);

	}

}



void dfs(int u, int par){

	for(int v:g[u]){

		if (v == par) continue;

		dfs(v, u);

	}

}

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

#define F first

#define S second

#define PB push_back

#define MP make_pair

#define endl '\n'



using namespace std;

typedef long long ll;

typedef vector<int> vi;

typedef pair<int,int> pi;





int main()

{

    ll a,b,c,d,ans=-1e18;

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

    ans=max(ans,a*c);

    ans=max(ans,a*d);

    ans=max(ans,b*c);

    ans=max(ans,b*d);

    cout<<ans<<endl;

    return 0;

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

using namespace std;



#define ll long long

#define endl "\n"



vector<ll> adj[100005];

ll vis[100005];

ll n, m;



void add(ll x, ll y) {

  adj[x].push_back(y);

  adj[y].push_back(x);

}



void solve() {

  ll a, b, c, d;

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

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

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

  ll ans3 = max(a, b) * max(c, d);

  ll ans4 = min(a, b) * min(c, d);

  ll ans5 = max(max(ans1, ans2), max(ans3, ans4));

  cout << ans5 << endl;

}



int main() {

  ll t;

  // cin >> t;

  t = 1;

  while (t--)

    solve();

  return 0;

}

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

using namespace std;



#define ll long long

#define endl "\n"



int main() {

  ll a, b, c, d;

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

  ll ans1 = a * c;

  ll ans2 = a * d;

  ll ans3 = b * c;

  ll ans4 = b * d;

  cout << max(max(ans1, ans2), max(ans3, ans4)) << endl;

  return 0;

}
// Slower C++ solution:
#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';

}

// Faster C++ solution for the same problem (measured speedup: 5.31657844358499x):
#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;

}
// Slower C++ solution:
#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;

}

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


// Faster C++ solution for the same problem (measured speedup: 5.248909228802322x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.183895731597789x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.244333927658976x):
#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;

}
// Slower C++ solution:
/*

* @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;



}


// Faster C++ solution for the same problem (measured speedup: 5.318509389462543x):
#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;

}
// Slower C++ solution:
#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;}




// Faster C++ solution for the same problem (measured speedup: 5.250607017154114x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.24900682962706x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.366056236743759x):
#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;

}
// Slower C++ solution:
/**



         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;

}

// Faster C++ solution for the same problem (measured speedup: 5.24900682962706x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.23400908926287x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.232782389261118x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.164766255235381x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.165753456665362x):
#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;

}