#include <bits/stdc++.h>
using namespace std;
int c[13];
bool use[24];
int main() {
  int n;
  cin >> n;
  c[0]++;
  for (int i = 0; i < n; i++) {
    int d;
    cin >> d;
    c[d]++;
  }
  int ans = 0;
  for (int i = 0; i < (1 << 11); i++) {
    fill(use, use + 24, false);
    int tmp = 30;
    for (int j = 0; j <= 12; j++) {
      if (c[j]) {
        if (j == 0 || j == 12) {
          if (c[j] >= 2) tmp = 0;
          use[j] = true;
        } else {
          if (c[j] >= 3)
            tmp = 0;
          else if (c[j] == 2) {
            use[j] = use[24 - j] = true;
          } else if (c[j] == 1) {
            use[i & (1 << (j - 1)) ? j : 24 - j] = true;
          }
        }
      }
    }
    for (int j = 0; j < 24; j++) {
      if (use[j]) {
        for (int k = 0; k < j; k++) {
          if (use[k]) {
            tmp = min(tmp, j - k);
          }
        }
      }
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}
