#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e9
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
 
ll n, a[51], used[51];
vector <ll> b;
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	for(int i = 0; i <= n; i++){
		if(!used[a[i]]){
			used[a[i]]=1;
		}
		b.pb(a[i]);
	}
	sort(b.begin(),b.end());
	for(int i = 0; i < b.size(); i++){
		if(i%2){
			b[i]=24-b[i];
		}
	}
	ll ans=INF;
	for(int i = 0; i <= b.size(); i++){
		for(int j = i+1; j <= b.size(); j++){
			ans=min(ans,abs(b[i]-b[j]));
		}
	}
	cout << ans;
	return 0;
}
