#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> D(N);
  for (int i = 0; i < N; i++) {
    cin >> D[i];
  }
  vector<int> pos;
  pos.push_back(0);
  for (int i = 0; i < N; i++) {
    int min1 = INT_MAX, min2 = INT_MAX;
    for (int e : pos) {
      min1 = min(min1, abs(e - D[i]));
      min2 = min(min2, abs(e - 24 + D[i]));
    }
    if (min1 >= min2) {
      pos.push_back(D[i]);
    } else {
      pos.push_back(24 - D[i]);
    }
  }
  sort(pos.begin(), pos.end());
  int ans = INT_MAX;
  for (int i = 1; i < pos.size(); i++) {
    ans = min(ans, min(pos[i] - pos[i - 1], 24 - pos[i] + pos[i - 1]));
  }
  cout << ans << endl;
}
