#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> D(N);
  for (int(i) = 0; (i) < (int)(N); (i)++) cin >> D[i];
  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  set<int> use;
  for (int(i) = 0; (i) < (int)(D.size()); (i)++) use.insert(D[i]);
  D.clear();
  for (auto x : use) D.push_back(x);
  if (D.size() == 1) {
    cout << abs(D[0] - (24 - D[0])) << endl;
    return 0;
  }
  int ans = 0;
  for (int(i) = 0; (i) < (int)((1 << D.size())); (i)++) {
    vector<int> Dt = D;
    for (int(j) = 0; (j) < (int)(D.size()); (j)++) {
      if ((i >> j) & 1) Dt[j] = 24 - Dt[j];
    }
    int diff = 1e9;
    for (int(j) = 0; (j) < (int)(N); (j)++)
      for (int(k) = 0; (k) < (int)(N); (k)++) {
        if (j != k) {
          diff = min(diff, abs(Dt[j] - Dt[k]));
        }
      }
    ans = max(ans, diff);
  }
  cout << ans << endl;
  return 0;
}
