#include <bits/stdc++.h>
using namespace std;
int N;
int num[13];
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    int D;
    scanf("%d", &D);
    num[D]++;
  }
  num[0]++;
  vector<int> va;
  for (int i = 0; i < 13; i++) {
    for (int j = 0; j < min(2, num[i]); j++) {
      va.push_back(i);
    }
  }
  int res = 0;
  for (int i = 0; i < (1 << va.size()); i++) {
    int min_diff = 13;
    for (int j = 0; j < va.size(); j++) {
      int time_j = (i & (1 << j) ? va[j] : ((24 - va[j]) % 24));
      for (int k = 0; k < va.size(); k++) {
        if (k == j) continue;
        int time_k = (i & (1 << k) ? va[k] : ((24 - va[k]) % 24));
        min_diff = min(min_diff, abs(time_j - time_k));
      }
    }
    res = max(res, min_diff);
  }
  printf("%d\n", res);
  return 0;
}
