#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, 0)));
vector<int> d(51, 0);
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  if (n == 1) {
    int d;
    cin >> d;
    cout << d << endl;
    return 0;
  }
  priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> que;
  for (int i = 1; i <= n; i++) {
    cin >> d[i];
    for (int j = 0; j < i; j++) {
      int dd = abs(d[i] - d[j]);
      dd = min(dd, 24 - dd);
      que.push(vector<int>{dd, 0, j, i});
      dd = abs(24 - d[i] - d[j]);
      dd = min(dd, 24 - dd);
      que.push(vector<int>{dd, 1, j, i});
    }
  }
  int ans;
  while (true) {
    vector<int> v = que.top();
    que.pop();
    a[v[1]][v[2]][v[3]] = 1;
    if (a[1 - v[1]][v[2]][v[3]]) {
      ans = v[0];
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
