#include <bits/stdc++.h>
using namespace std;
int cnt[13];
int ans;
bool used[24];
void dfs(int d, int m) {
  if (cnt[d] >= 3) {
    ans = 0;
  } else if (cnt[d] == 2) {
    int tmp = m;
    for (int i = 0; i < 24; i++) {
      if (used[i]) {
        tmp = min(tmp, min(24 - 2 * d, 2 * d));
        tmp = min(tmp, min(abs(d - i), 24 - abs(d - i)));
        tmp = min(tmp, min(abs(d - (24 - i)), 24 - abs(d - (24 - i))));
      }
    }
    if (d == 12) {
      ans = 0;
    } else {
      used[d] = true;
      used[24 - d] = true;
      dfs(d + 1, tmp);
      used[d] = false;
      used[24 - d] = false;
    }
  } else if (cnt[d] == 1) {
    int tmp = m;
    for (int i = 0; i < 24; i++) {
      if (used[i]) {
        tmp = min(tmp, min(abs(d - i), 24 - abs(d - i)));
      }
    }
    if (d == 12) {
      ans = max(ans, tmp);
    } else {
      used[d] = true;
      dfs(d + 1, tmp);
      used[d] = false;
    }
    tmp = m;
    for (int i = 0; i < 24; i++) {
      if (used[i]) {
        tmp = min(tmp, min(abs(24 - d - i), 24 - abs(24 - d - i)));
      }
    }
    if (d == 12) {
      ans = max(ans, tmp);
    } else {
      used[24 - d] = true;
      dfs(d + 1, tmp);
      used[d] = false;
    }
  } else {
    if (d == 12) {
      ans = max(ans, m);
    } else {
      dfs(d + 1, m);
    }
  }
}
int main() {
  int N;
  int D[50];
  cin >> N;
  for (int i = 0; i < N; i++) {
    int D;
    cin >> D;
    cnt[D]++;
  }
  if (cnt[0] != 0) {
    cout << 0 << endl;
    return 0;
  }
  used[0] = true;
  dfs(1, 12);
  cout << ans << endl;
}
