#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 minI, minN = 114514;
    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]) {
        minI = i;
        minN = v[i];
      }
    }
    D[minI] = 24 - D[minI];
    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])));
      }
    }
  } while (ans < res);
  std::cout << ans << std::endl;
  return 0;
}
