#include <bits/stdc++.h>
using namespace std;
int getTime(vector<int>& time, int d) {
  time[d]++;
  vector<int> c;
  int diff_max = 24;
  for (int i = 0; i < time.size(); i++)
    if (time[i] >= 2) return 0;
  for (int i = 0; i < time.size(); i++)
    if (time[i] == 1) c.push_back(i);
  for (int i = 0; i < c.size() - 1; i++)
    diff_max = min(c[i + 1] - c[i], diff_max);
  diff_max = min({diff_max, c.back(), 24 - c.back()});
  return diff_max;
}
int main() {
  int N;
  cin >> N;
  vector<int> D(N);
  for (int i = 0; i < N; i++) cin >> D[i];
  int ans = 0;
  for (int i = 0; i <= 12; i++) {
    bool good = true;
    vector<int> time(24, 0);
    time[0] = 1;
    for (int j = 0; j < N; j++) {
      int d1 = D[j];
      int d2 = 24 - D[j];
      vector<int> time1 = time, time2 = time;
      int diff1 = getTime(time1, d1);
      int diff2 = getTime(time2, d2);
      if (diff1 < i && diff2 < i) {
        good = false;
        break;
      }
      if (diff1 >= i && diff2 < i) {
        time = time1;
        continue;
      }
      if (diff1 < i && diff2 >= i) {
        time = time2;
        continue;
      }
      if (diff1 >= i && diff2 >= i) {
        if (diff1 >= diff2) {
          time = time2;
        } else {
          time = time1;
        }
      }
    }
    if (good) ans = i;
  }
  cout << ans << endl;
}
