#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int t[30] = {}, d[N + 1];
  for (int i = 0; i < N; i++) {
    int dv;
    cin >> dv;
    t[dv]++;
    d[i] = dv;
  }
  t[0]++;
  d[N] = 0;
  for (int i = 0; i <= 12; i++) {
    if (t[i] >= 3 || t[0] >= 2) {
      cout << 0 << endl;
      return 0;
    }
  }
  int vmin = 99999;
  for (int i = 1; i <= 12; i++) {
    if (t[i] > 0) {
      vmin = i;
      break;
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      int mx = max(abs(d[i] - d[j]), abs(24 - d[i] - d[j]));
      vmin = min(vmin, mx);
    }
  }
  cout << vmin << endl;
  return 0;
}
