#include <bits/stdc++.h>
using namespace std;
int n;
int d[55];
int cnt[55];
vector<int> newd;
vector<int> extra;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", d + i);
  for (int i = 1; i <= n; i++) {
    cnt[d[i]]++;
  }
  for (int i = 0; i <= 12; i++) {
    if (cnt[i] > 2) {
      printf("0");
      return 0;
    } else if (cnt[i] == 2) {
      extra.push_back(i);
      extra.push_back(24 - i);
    } else if (cnt[i] == 1) {
      newd.push_back(i);
    }
  }
  int ans = 0;
  for (int i = 0; i < (1 << (newd.size())); i++) {
    vector<int> seq;
    for (int j = 0; j < newd.size(); j++) {
      if (i & (1 << j)) {
        seq.push_back(newd[j]);
      } else {
        seq.push_back(24 - newd[j]);
      }
    }
    seq.push_back(0);
    for (int j = 0; j < extra.size(); j++) {
      seq.push_back(extra[j]);
    }
    int cursiz = seq.size();
    for (int j = 0; j < cursiz; j++) {
      seq.push_back(seq[j]);
    }
    sort(seq.begin(), seq.end());
    int mind = 100000;
    for (int j = 1; j < seq.size(); j++) {
      mind = min(mind, min(seq[j] - seq[j - 1], 24 - seq[j] + seq[j - 1]));
    }
    ans = max(ans, mind);
  }
  printf("%d", ans);
  return 0;
}
