#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
    int N, D[51] = {}, pos[51] = {};
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> D[i];
    }
    sort(D, D+(N+1));
    bool right = true;
    for(int i = 0; i <= N; i++){
        if(right){
            pos[i] = D[i];
        }else{
            pos[i] = (24-D[i])%24;
        }
        right = !right;
    }
    sort(pos, pos+(N+1));
    for(int i = 0; i <= N; i++){
        //printf("%d: %d\n", i, pos[i]);
    }
    int ans = 10000;
    for(int i = 0; i < N; i++){
        ans = min(ans, pos[i+1] - pos[i]);
    }
    ans = min(ans, 24 - pos[N]);
    cout << ans << endl;
}


        
    