#include <bits/stdc++.h>
using namespace std;
template <class T>
using vv = vector<vector<T> >;
template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1) s << "\t";
  }
  s << "\n";
  return s;
}
void print_ans(int x) {
  printf("%d\n", x);
  exit(0);
}
int min_d(vector<bool>& ex) {
  vector<int> a;
  for (int(i) = (0); (i) < ((int)ex.size()); ++(i)) {
    if (ex[i]) {
      a.push_back(i);
    }
  }
  int ret = a.front() + 24 - a.back();
  for (int(i) = (0); (i) < ((int)a.size() - 1); ++(i)) {
    ret = min(ret, a[i + 1] - a[i]);
  }
  return ret;
}
int main() {
  int n;
  scanf("%d", &n);
  vector<int> d(n, 0);
  for (int(i) = (0); (i) < (n); ++(i)) {
    scanf("%d", &d[i]);
  }
  vector<int> acc(13, 0);
  for (int(i) = (0); (i) < (n); ++(i)) {
    acc[d[i]] += 1;
  }
  if (acc[0] >= 1) {
    print_ans(0);
  }
  for (int(i) = (1); (i) < (12); ++(i)) {
    if (acc[i] >= 3) {
      print_ans(0);
    }
  }
  if (acc[12] >= 2) {
    print_ans(0);
  }
  vector<bool> exist;
  int ans = 24;
  for (int(i) = (0); (i) < ((1 << n)); ++(i)) {
    exist.assign(24, false);
    exist[0] = true;
    bool continue_flag = false;
    for (int(j) = (0); (j) < (n); ++(j)) {
      int target;
      if (((i >> j) & 1) == 0) {
        target = d[j];
      } else {
        target = 24 - d[j];
      }
      if (exist[target]) {
        continue_flag = true;
        break;
      }
      exist[target] = true;
    }
    if (continue_flag) {
      continue;
    }
    ans = min(ans, min_d(exist));
  }
  print_ans(ans);
  return 0;
}
