#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int c[13] = {1};
  for (int i = 0; i < n; i++) {
    int d;
    cin >> d;
    c[d]++;
  }
  int r = 12;
  int x[24] = {};
  for (int i = 0; i <= 12; i++) {
    if (c[i] > 2 || (i % 12 == 0 && c[i] > 1)) {
      r = 0;
      break;
    }
    for (int j = 0; j < c[i]; j++) {
      x[j == i % 2 ? i : 24 - i]++;
    }
  }
  int j = -r;
  for (int i = 0; i <= 24; i++) {
    if (i == 24 || x[i]) {
      r = min(r, i - j);
      j = i;
    }
  }
  cout << r << endl;
  return 0;
}
