#include <bits/stdc++.h>
int N, res, ans;
std::vector<int> D, v;
int main() {
  std::cin >> N;
  D.push_back(0);
  for (int i = 0; i < N; ++i) {
    int tmp;
    std::cin >> tmp;
    D.push_back(tmp);
  }
  ++N;
  v.resize(N);
  res = 114514;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      if (i == j) {
        continue;
      }
      res = std::min(res, std::min(abs(D[i] - D[j]), 24 - abs(D[i] - D[j])));
    }
  }
  do {
    ans = res;
    int minN = 114514;
    std::vector<int> list;
    for (int i = 0; i < N; ++i) {
      v[i] = 114514;
      for (int j = 0; j < N; ++j) {
        if (i == j) {
          continue;
        }
        v[i] =
            std::min(v[i], std::min(abs(D[i] - D[j]), 24 - abs(D[i] - D[j])));
      }
      if (minN > v[i]) {
        list.clear();
        minN = v[i];
      }
      if (minN == v[i]) {
        list.push_back(i);
      }
    }
    int maxR = -1, maxI;
    for (auto i : list) {
      auto bef = D[i];
      D[i] = 24 - D[i];
      res = 114514;
      for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
          if (i == j) {
            continue;
          }
          res =
              std::min(res, std::min(abs(D[i] - D[j]), 24 - abs(D[i] - D[j])));
        }
      }
      if (maxR < res) {
        maxI = i;
        maxR = res;
      }
      D[i] = bef;
    }
  } while (ans < res);
  std::cout << ans << std::endl;
  return 0;
}
