#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;
const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;
const double PI11 = 3.14159265359;
const int dis[5] = {0, 1, 0, -1, 0};
const int disD[4] = {0, 1, 1, 0};
const int disLD[3] = {0, 1, 0};
const char disC[4] = {'U', 'D', 'R', 'L'};
const char disY[4] = {-1, 1, 0, 0};
const char disX[4] = {0, 0, 1, -1};
ll gcd(ll a, ll b) {
  if (a % b == 0) return b;
  return gcd(b, a % b);
}
vector<int> day;
int flag[25] = {};
int D[13] = {};
int solve(int i) {
  if (i == day.size()) {
    int result = 50;
    for (int j = 0; j < 25; j++) {
      if (flag[j] >= 2) {
        result = 0;
        break;
      }
      for (int k = j + 1; k < 25; k++) {
        if (j == k) continue;
        if (flag[j] == 1 && flag[k] == 1) {
          int s = j - 12, t = k - 12;
          s = (s < 0) ? 24 + s : s;
          t = (t < 0) ? 24 + t : t;
          result = std::min(result, abs(s - t));
        }
      }
    }
    return result;
  }
  int result = 0;
  if (D[day[i]] == 2) {
    flag[12 + day[i]]++;
    flag[12 - day[i]]++;
    result = solve(i + 1);
    flag[12 + day[i]]--;
    flag[12 - day[i]]--;
  } else {
    flag[12 + day[i]]++;
    result = std::max(result, solve(i + 1));
    flag[12 + day[i]]--;
    flag[12 - day[i]]++;
    result = std::max(result, solve(i + 1));
    flag[12 - day[i]]--;
  }
  return result;
}
int main(void) {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int d;
    cin >> d;
    D[d]++;
  }
  for (int i = 0; i < 13; i++) {
    if (D[i] >= 3) {
      cout << 0 << endl;
      return 0;
    } else {
      if (D[i] > 0) day.push_back(i);
    }
  }
  flag[12] = 1;
  cout << solve(0) << endl;
  return 0;
}
