#include <bits/stdc++.h>
int N, res, ans;
std::vector<int> D, v;
int main() {
  std::cin >> N;
  D.resize(N);
  v.resize(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> D[i];
  }
  if (N == 1) {
    std::cout << 0 << std::endl;
    return 0;
  }
  res = 114514;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      if (i == j) {
        continue;
      }
      res = std::min(res, abs(D[i] - D[j]));
    }
  }
  do {
    ans = res;
    int minI, minN = 114514;
    for (int i = 0; i < N; ++i) {
      v[i] = 0;
      for (int j = 0; j < N; ++j) {
        if (i == j) {
          continue;
        }
        v[i] += 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, abs(D[i] - D[j]));
      }
    }
  } while (ans < res);
  std::cout << ans << std::endl;
  return 0;
}
