In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi.

Takahashi checked and found that the time gap (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example.

Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours.

Find the maximum possible value of s.

Constraints

* 1 \leq N \leq 50
* 0 \leq D_i \leq 12
* All input values are integers.

Input

Input is given from Standard Input in the following format:


N
D_1 D_2 ... D_N


Output

Print the maximum possible value of s.

Examples

Input

3
7 12 8


Output

4


Input

2
11 11


Output

2


Input

1
0


Output

0
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int n;
int d[55];
vector<P> a;
bool used[101];

bool ok(int x){
  int i=0;
  int crth=0;
  int cnt=1;
  memset(used,0,sizeof(used));
  used[0]=true;
  while(1){
    while(i<a.size()&&(a[i].fi-crth<x||used[a[i].se]))i++;
    if(i==a.size())return false;
    used[a[i].se]=true;
    cnt++;
    if(cnt==n+1){
      if(min(a[i].fi,24-a[i].fi)>=x)return true;
      else return false;
    }
    crth=a[i].fi;
  }
  return false;
}

int main(){
	cin>>n;
  rep(i,n){
    cin>>d[i];
    if(d[i]==0||d[i]==12){
      a.push_back(P(d[i],i+1));
    }else{
      a.push_back(P(d[i],i+1));
      a.push_back(P(24-d[i],i+1));
    }
  }
  a.push_back(P(0,0));
  sort(all(a));
  rep(x,51){
    if(!ok(x)){
      cout<<x-1<<endl;
      return 0;
    }
  }
	return 0;
}
