#include <bits/stdc++.h>
int N, res, ans;
std::vector<int> D, list;
int main() {
  std::cin >> N;
  D.resize(N + 1);
  for (int i = 0; i < N; ++i) {
    std::cin >> D[i + 1];
  }
  for (int bit = 0; bit < (1 << D.size()); ++bit) {
    int k = 0;
    res = 114514;
    list.clear();
    for (auto i : D) {
      if (bit & (1 << k)) {
        list.push_back(24 - i);
      } else {
        list.push_back(i);
      }
      ++k;
    }
    for (auto i : list) {
      for (auto j : list) {
        if (i == j) {
          continue;
        }
        res = std::min(res, std::min(abs(i - j), 24 - abs(i - j)));
      }
    }
    ans = std::max(ans, std::min(res, 12 - res));
  }
  std::cout << ans << std::endl;
  return 0;
}
