#include <bits/stdc++.h>
using namespace std;
template <class T>
T mymax(T a, T b) {
  if (a >= b) {
    return a;
  }
  return b;
}
template <class T>
T mymin(T a, T b) {
  if (a <= b) {
    return a;
  }
  return b;
}
struct XX {
  long long x;
  long long y;
  long long ix;
  long long iy;
};
class xxGreater {
 public:
  bool operator()(const XX& riLeft, const XX& riRight) const {
    if ((riLeft.x) == (riRight.x)) {
      return riLeft.y < riRight.y;
    }
    return (riLeft.x) < (riRight.x);
  }
};
int main(int argc, const char* argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  int D[51];
  D[0] = 0;
  for (int i = 1; i <= N; i++) {
    cin >> D[i];
  }
  int taka[51][2];
  taka[0][0] = 0;
  taka[0][1] = 24;
  for (int i = 1; i <= N; i++) {
    taka[i][0] = D[i];
    taka[i][1] = 24 - (D[i]);
  }
  int tmp1 = min(D[1], 24 - (D[1]));
  int tmp2 = min(D[1], 24 - (D[1]));
  set<int> tosi;
  tosi.clear();
  tosi.insert(0);
  tosi.insert(D[1]);
  tosi.insert(24 - D[1]);
  for (int p = 2; p <= N; p++) {
    for (auto it : tosi) {
      int pp;
      if (it - D[p] >= 0) {
        pp = it - D[p];
      } else {
        pp = it - D[p] + 24;
      }
      if (min(pp, 24 - pp) >= tmp2) {
      } else if (tmp2 > min(pp, 24 - pp) && min(pp, 24 - pp) > tmp1) {
        tmp2 = min(pp, 24 - pp);
      } else if (min(pp, 24 - pp) == tmp1) {
      } else {
        tmp2 = tmp1;
        tmp1 = min(pp, 24 - pp);
      }
      if (it - (24 - D[p]) >= 0) {
        pp = it - (24 - D[p]);
      } else {
        pp = it - (24 - D[p]) + 24;
      }
      if (min(pp, 24 - pp) >= tmp2) {
      } else if (tmp2 > min(pp, 24 - pp) && min(pp, 24 - pp) > tmp1) {
        tmp2 = min(pp, 24 - pp);
      } else if (min(pp, 24 - pp) == tmp1) {
      } else {
        tmp2 = tmp1;
        tmp1 = min(pp, 24 - pp);
      }
    }
    tosi.insert(D[p]);
    tosi.insert(24 - D[p]);
  }
  cout << tmp2 << endl;
  return 0;
}
