/*
  ID: oodt
  PROG:
  LANG:C++
*/
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<set>

using namespace std;

const int maxx=10005;
int n,m,k;
vector<int> a;
int ans = 0,cnt = 0,pos = 0;
int l = 0,r = 0;

int main()
{
#ifdef LOCAL
//    freopen("","r",stdin);
#endif
    scanf("%d",&n);
    for(int i = 0; i < n; i++)
    {
        int x;
        scanf("%d",&x);
        a.push_back(x);
    }
    a.push_back(0);
    int mi = 24;
    sort(a.begin(),a.end());
    for(int i = 1; i <= n; i++)
    {
        if(i%2) a[i] *= -1;
    }
    sort(a.begin(),a.end());
    for(int i = 1; i <= n; i++)
    {
        mi = min(mi,a[i]-a[i-1]);
    }
    mi = min(mi,a[0]+24-a[n]);
    printf("%d\n",mi);
    return 0;
}
