#include<bits/stdc++.h>

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vector<int> vc;
    vc.push_back(0);
    for(int i = 0; i < n; i++){
        int x; cin >> x;
        vc.push_back(x);
    }
    sort(vc.begin(), vc.end());

    for(int i = 0; i <= n; i+=2){
        vc[i] = (24 - vc[i]) % 24;
    }

    sort(vc.begin(), vc.end());

    int minimum = 100;

    for(int i = 1; i <= n; i++){
        minimum = min(vc[i] - vc[i - 1], minimum);
    }
    cout << minimum;
}
