#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  vector<int> cnt(13, 0);
  for (int i = 0; i < n; i++) {
    cin >> d[i];
    cnt[d[i]]++;
  }
  d.push_back(0);
  cnt[0]++;
  vector<int> a;
  for (int i = 0; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (cnt[d[i]] >= 2 || cnt[d[j]] >= 2) {
        a.push_back(abs(d[i] - d[j]));
      } else {
        a.push_back(min(d[i] + d[j], 24 - d[i] - d[j]));
      }
    }
  }
  sort((a).begin(), (a).end());
  cout << a[0] << endl;
  return 0;
}
