#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int main() {
  int N;
  cin >> N;
  int D[N];
  for (int i = 0; i < (N); i++) cin >> D[i];
  int a[2] = {D[0], 24 - D[0]};
  int mi = 0;
  for (int i = 0; i < (2); i++) {
    vector<int> tmp;
    tmp.push_back(a[i]);
    int mm = 20;
    for (int j = 0; j < (N - 1); j++) {
      int x = D[j + 1], y = 24 - D[j + 1];
      int mix = 20, miy = 20;
      for (int k = 0; k < (tmp.size()); k++) {
        mix = min(mix, abs(x - tmp[k]));
        miy = min(miy, abs(y - tmp[k]));
      }
      if (mix > miy)
        tmp.push_back(x);
      else
        tmp.push_back(y);
      mm = min(mm, max(mix, miy));
    }
    if (mm == 20) continue;
    mi = max(mi, mm);
  }
  cout << mi << endl;
  return 0;
}
