#include <bits/stdc++.h>
using namespace std;
struct edge {
  int from, to;
  long long cost;
};
int n;
int a[51][51];
vector<int> d(51);
pair<int, int> calc_min() {
  int min_i, min_j, min_ = 1410065408;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i == j) continue;
      a[i][j] = abs(d[i] - d[j]);
      if (min_ > a[i][j]) {
        min_ = a[i][j];
        min_i = i;
        min_j = j;
      }
    }
  }
  return pair<int, int>(min_i, min_j);
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  a[0][0] = 1410065408;
  for (int i = 1; i <= n; i++) {
    cin >> d[i];
    a[0][i] = d[i];
    a[i][0] = d[i];
    a[i][i] = 1410065408;
  }
  int ans = 12;
  while (true) {
    pair<int, int> min_pair = calc_min();
    int i = min_pair.first, j = min_pair.second;
    int min_ = a[i][j];
    d[i] = 24 - d[i];
    pair<int, int> min_pair_i = calc_min();
    int ii = min_pair_i.first, ij = min_pair_i.second;
    d[i] = 24 - d[i];
    d[j] = 24 - d[j];
    pair<int, int> min_pair_j = calc_min();
    int ji = min_pair_j.first, jj = min_pair_j.second;
    if (a[ii][ij] >= a[ji][jj]) {
      if (a[ii][ij] > min_) {
        d[i] = 24 - d[i];
        d[j] = 24 - d[j];
      } else {
        ans = min_;
        break;
      }
    } else {
      if (a[ji][jj] > min_) {
      } else {
        ans = min_;
        break;
      }
    }
    cout << min_ << endl;
  }
  if (ans == 1410065408) ans = 0;
  cout << ans << endl;
}
