#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> jikoku{0, 24};
  for (int i = (0); i < (n); ++i) {
    int d;
    cin >> d;
    if (d == 0) {
      cout << 0 << '\n';
      return 0;
    }
    int index1 = distance(jikoku.begin(),
                          lower_bound((jikoku).begin(), (jikoku).end(), d)),
        index2 = distance(jikoku.begin(), lower_bound((jikoku).begin(),
                                                      (jikoku).end(), 24 - d));
    int sa1 = min(jikoku[index1] - d, d - jikoku[index1 - 1]),
        sa2 = min(jikoku[index2] - (24 - d), (24 - d) - jikoku[index2 - 1]);
    if (sa1 >= sa2)
      jikoku.push_back(d);
    else
      jikoku.push_back(24 - d);
    sort((jikoku).begin(), (jikoku).end());
  }
  int ans = 12;
  for (int i = (0); i < (jikoku.size() - 1); ++i)
    ans = min(ans, jikoku[i + 1] - jikoku[i]);
  cout << ans << '\n';
  return 0;
}
