#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define rep(i, n) for(int i = 0 ; i < n ; i++)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n){
        cin >> d[i];
    }
    d.push_back(0);
    SORT(d);
    int sign = 1;
    rep(i, n+1){
        d[i] *= sign;
        sign = -sign;
    }
    vector<int> a;
    for(int i = 0 ; i < n ; i++){
        for(int j = i + 1 ; j < n + 1 ; j++){
            a.push_back(min(abs(d[i] - d[j]), 24 - abs(d[i]) - abs(d[j])));
        }
    }
    SORT(a);
    cout << a[0] << endl;
    return 0;
}