#include <bits/stdc++.h>
using namespace std;
void func(void);
signed int main(void) {
  func();
  ;
  return 0;
}
int dmin(int val_d) { return min((val_d), 24 - (val_d)); }
int calcMin(vector<int> &d) {
  int n = d.size();
  int m = (2147483647);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) {
        continue;
      }
      m = min(m, dmin(abs(d[i] - d[j])));
    }
  }
  return m;
}
int calcMax(vector<int> &d) {
  int n = (int)pow(2, d.size());
  int valMax = (-2147483648);
  for (unsigned int i = 0; i < n; i++) {
    vector<int> dd = d;
    for (int j = 0; j < 12; j++) {
      if (((i >> j) & 1) == 1) {
        dd[j] = 24 - dd[j];
      }
    }
    int val = calcMin(dd);
    valMax = max(valMax, val);
  }
  return valMax;
}
void func(void) {
  int n;
  cin >> n;
  vector<int> D;
  vector<int> list(13, 0);
  for (int i = 0; i < n; i++) {
    int v;
    cin >> v;
    list[v]++;
  }
  for (int i = 0; i < 13; i++) {
    if (list[i] == 1) {
      D.push_back(i);
    } else if (list[i] > 1) {
      D.push_back(i);
      D.push_back(i);
    } else {
    }
  }
  int ans = calcMax(D);
  cout << ans << endl;
}
