#include <bits/stdc++.h>
int N, D[50];
int cnt[13];
int used;
int main() {
  scanf("%d", &N);
  for (int i = (0); i < (N); ++i)
    scanf("%d", D + i), ++cnt[D[i]], used |= 1 << D[i];
  if (N == 1) {
    puts("0");
    return 0;
  }
  for (int i = (0); i < (13); ++i)
    if (cnt[i] >= 3) {
      puts("0");
      return 0;
    }
  int ans = 0;
  for (int i = 0; i < (1 << 11); ++i) {
    int st = (i << 1) & used;
    int mi = 24;
    for (int j = (0); j < (13); ++j)
      for (int k = (0); k < (j); ++k) {
        std::vector<int> us, vs;
        if (cnt[j] == 2)
          us.push_back(j), us.push_back(24 - j);
        else if (cnt[j] == 1)
          us.push_back(j + (st >> j & 1 ? 24 - 2 * j : 0));
        if (cnt[k] == 2)
          vs.push_back(k), vs.push_back(24 - k);
        else if (cnt[k] == 1)
          vs.push_back(k + (st >> k & 1 ? 24 - 2 * k : 0));
        for (auto &u : us)
          for (auto &v : vs) mi = std::min(mi, abs(u - v));
        if (us.size() > 1) mi = std::min(mi, abs(us[1] - us[0]));
        if (vs.size() > 1) mi = std::min(mi, abs(vs[1] - vs[0]));
      }
    ans = std::max(ans, mi);
  }
  printf("%d\n", ans);
  return 0;
}
