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