#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;

    int c[13] = { 1 };
    for (int i = 0; i < n; i++) {
        int d;
        cin >> d;

        c[d]++;
    }

    int r = 12;
    int k = 0;
    int x[24] = {};
    for (int i = 0; i <= 12; i++) {
        if (c[i] > 2 || (i % 12 == 0 && c[i] > 1)) {
            r = 0;
            break;
        }
        for (int j = 0; j < c[i]; j++) {
            x[j == k ? i : 24 - i]++;
        }
        if (c[i] == 1) k ^= 1;
    }

    int j = -r;
    for (int i = 0; i <= 24; i++) {
        if (i == 24 || x[i]) {
            r = min(r, i - j);
            j = i;
        }
    }

    cout << r << endl;

    return 0;
}