#include <bits/stdc++.h>
int N, ans;
int main() {
  std::cin >> N;
  std::vector<int> D(N);
  for (int i = 0; i < N; ++i) std::cin >> D[i];
  std::sort(D.begin(), D.end());
  for (int i = 0; i < N; ++i) {
    if (i % 2) D[i] = 24 - D[i];
  }
  ans = 24;
  for (int i = 0; i < N; ++i) {
    auto d = abs(D[i] - D[(i + 1) % N]);
    ans = std::min(ans, std::min(d, 24 - d));
  }
  std::cout << ans << std::endl;
  return 0;
}
