#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>

int solve(int N, std::vector<int> D)
{
    N++;
    D.emplace_back(0);
    
    if (N > 24) {
        return 0;
    }
    
    std::vector<int> cnt(13);
    for (int i = 0; i < N; i++) {
        cnt[D[i]]++;
        if (cnt[D[i]] == 3) {
            return 0;
        }
    }

    if (N > 12) {
        return 1;
    }
    
    int ret = 0;
    for (int i = 0; i < (1 << N); i++) {
        std::vector<int> d(N, 0);
        for (int j = 0; j < N; j++) {
            if (i >> j & 1) {
                d[j] = D[j] % 24;
            } else {
                d[j] = (24 - D[j]) % 24;
            }
        }
        
        int score = 10000000;
        for (int j = 0; j < N; j++) {
            for (int k = j + 1; k < N; k++) {
                int min, max;
                std::tie(min, max) = std::minmax(d[j], d[k]);
                
                int diff = std::min((max - min) % 24, (24 - (max - min)) % 24);                
                score = std::min(score, diff);
            }
        }

        
        ret = std::max(ret, score);
    }
    
    return ret;
}

int main()
{
    int N;
    std::cin >> N;
    
    std::vector<int> D(N);
    for (int i = 0; i < N; i++) {
        std::cin >> D[i];
    }
    
    std::cout << solve(N, D) << std::endl;

    return 0;
}
