#include <bits/stdc++.h>
using namespace std;

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << (a) << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

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

    int n; cin >> n;
    vi a(n+1); forn(i,n) cin >> a[i+1];
    sort(all(a));
    for (int i = 1; i < si(a); i += 2) a[i] = 24-a[i];
    sort(all(a)); a.pb(24);

    int ans = 24;
    forn(i,si(a)-1) ans = min(ans, a[i+1] - a[i]);
    cout << ans << endl;

    return 0;
}
