#include <bits/stdc++.h>
using namespace std;
struct edge {
  int from, to;
  long long cost;
};
int n;
vector<vector<vector<int> > > a(
    2, vector<vector<int> >(51, vector<int>(51, 1410065408)));
vector<int> d(51);
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  if (n == 1) {
    int d;
    cin >> d;
    cout << min(d, 24 - d) << endl;
    return 0;
  }
  a[0][0][0] = 1410065408;
  a[1][0][0] = 1410065408;
  for (int i = 1; i <= n; i++) {
    cin >> d[i];
    a[0][0][i] = d[i];
    a[0][i][0] = 1410065408;
    a[1][0][i] = 24 - d[i];
    a[1][i][0] = 1410065408;
    for (int j = 1; j <= i - 1; j++) {
      a[0][i][j] = 1410065408;
      a[0][j][i] = abs(d[i] - d[j]);
      a[1][i][j] = 1410065408;
      a[1][j][i] = abs(d[i] + d[j] - 24);
    }
    a[0][i][i] = 1410065408;
    a[1][i][i] = 1410065408;
  }
  vector<vector<int> > min_(2, vector<int>(n + 1));
  int ans = 12;
  for (int i = 0; i < n + 1; i++) {
    min_[0][i] = *min_element(a[0][i].begin(), a[0][i].end());
    min_[1][i] = *min_element(a[1][i].begin(), a[1][i].end());
    ans = min(ans, max(min_[0][i], min_[1][i]));
  }
  for (int j = 0; j < n + 1; j++) {
    for (int k = 0; k < 2; k++) min_[k][j] = 1410065408;
    for (int i = 0; i < n + 1; i++)
      for (int k = 0; k < 2; k++) min_[k][j] = min(min_[k][j], a[k][i][j]);
    ans = min(ans, max(min_[0][j], min_[1][j]));
  }
  cout << ans << endl;
  return 0;
}
