#include <bits/stdc++.h>
using namespace std;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
vector<int> G[100005];
std::vector<pair<long long, long long> > tree[100010];
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
long long i, j, k, l, ii, jj;
long long n, m;
long long x, y;
long long a[25], b[25];
long long ans = 0;
long long kouho = INF;
int main() {
  cin >> n;
  if (n >= 13) {
    ans = 1;
    for (i = 0; i < n; i++) {
      cin >> a[i];
      a[i] = min(a[i], 24 - a[i]);
    }
    b[0] = 1;
    for (i = 0; i < n; i++) {
      b[a[i]]++;
    }
    for (i = 0; i <= 12; i++) {
      if (b[i] >= 3) ans = 0;
    }
  } else {
    for (i = 0; i < n; i++) {
      cin >> a[i];
    }
    a[n] = 0;
    for (i = 0; i <= 2047; i++) {
      for (j = 0; j < n + 1; j++) {
        if (i & 1 << j) {
          b[j] = a[j];
        } else {
          b[j] = 24 - a[j];
        }
      }
      kouho = INF;
      for (k = 0; k < n + 1; k++) {
        for (j = 0; j < n + 1; j++) {
          if (k == j) continue;
          kouho = min(abs(b[k] - b[j]), kouho);
        }
      }
      ans = max(ans, kouho);
    }
  }
  ans = min(ans, 24 - ans);
  cout << ans << endl;
  ;
  return 0;
}
