#include <bits/stdc++.h>
using namespace std;
vector<int> bit, val;
int cnt[30];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    if (x < 12) {
      if (cnt[x] <= 1) {
        cnt[x]++;
      }
    } else {
      if (cnt[24 - x] <= 1) {
        cnt[24 - x]++;
      }
    }
  }
  for (int i = 0; i <= 12; i++) {
    if (cnt[i] == 2)
      bit.push_back(i), bit.push_back(i);
    else if (cnt[i] == 1)
      bit.push_back(i);
  }
  int ans = -1;
  for (int i = 0; i < 1 << bit.size(); i++) {
    int cur = 100;
    val.clear();
    val.push_back(0);
    for (int j = 0; j < bit.size(); j++) {
      if (i & (1 << j))
        val.push_back(bit[j]);
      else
        val.push_back(24 - bit[j]);
    }
    for (int j = 0; j < val.size(); j++) {
      for (int k = j + 1; k < val.size(); k++) {
        int t = val[j], tt = val[k];
        if (t > tt) swap(t, tt);
        tt -= t;
        cur = min(cur, min(tt, 24 - tt));
      }
    }
    ans = max(ans, cur);
  }
  printf("%d\n", ans);
  return 0;
}
