#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;
int main() {
  int n;
  cin >> n;
  vector<int> a(n), b;
  for (int i = (0); i < (n); i++) {
    cin >> a[i];
  }
  if (n == 1) {
    printf("0");
    return 0;
  }
  sort(a.begin(), a.end());
  b = a;
  int turn = 0;
  for (int i = (0); i < (13); i++) {
    if (turn) {
      int swi = 0;
      for (int j = (0); j < (n); j++) {
        if (a[j] == i && swi) a[j] = 24 - a[j];
        swi ^= 1;
      }
    }
    turn ^= 1;
  }
  sort(a.begin(), a.end());
  int ans = 25;
  for (int i = (0); i < (a.size() - 1); i++) ans = min(ans, a[i + 1] - a[i]);
  turn = 1;
  for (int i = (0); i < (13); i++) {
    if (turn) {
      int swi = 0;
      for (int j = (0); j < (n); j++) {
        if (b[j] == i && swi) b[j] = 24 - b[j];
        swi ^= 1;
      }
    }
    turn ^= 1;
  }
  sort(b.begin(), b.end());
  int sub = 25;
  for (int i = (0); i < (b.size() - 1); i++) sub = min(sub, b[i + 1] - b[i]);
  printf("%d", max(ans, sub));
  return 0;
}
