#include <bits/stdc++.h>
using namespace std;
template <typename T>
string join(const vector<T>& v) {
  stringstream s;
  for (int i = 0, i_len = ((int)(v).size()); i < i_len; ++i) s << ' ' << v[i];
  return s.str().substr(1);
}
template <typename T>
inline ostream& operator<<(ostream& o, const vector<T>& v) {
  if ((int)(v).size()) o << join(v);
  return o;
}
const long long int LINF = (long long int)1e18 + 7;
const int INF = 1e9 + 7;
const long long int MOD = 1e9 + 7;
int f(int a) {
  if (a < 12)
    return a;
  else if (a > 12)
    return (24 - a);
  return a;
}
int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i = 0, i_len = (n); i < i_len; ++i) {
    cin >> d[i];
  }
  if (n == 1) {
    puts("0");
    return 0;
  }
  int ans = 12;
  for (int i = 0, i_len = (n - 1); i < i_len; ++i)
    for (int j = (i + 1), j_len = (n); j < j_len; ++j) {
      int t;
      t = max(abs(d[i] - d[j]), f(d[i] + d[j]));
      ans = min(ans, t);
    }
  cout << ans << endl;
  return 0;
}
