#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] = 0;
  for (int i = 1; i <= N; i++) {
    taka[i][0] = D[i];
    taka[i][1] = 24 - (D[i]);
  }
  int tmpans = 0;
  int tmp1 = 0, tmp2 = 0, tmp3 = 0, tmp4 = 0;
  for (int p = 0; p <= N - 1; p++) {
    for (int q = p + 1; q <= N; q++) {
      int pp;
      if (taka[q][0] - taka[p][0] >= 0) {
        pp = taka[q][0] - taka[p][0];
      } else {
        pp = taka[q][0] - taka[p][0] + 24;
      }
      tmp1 = min(pp, 24 - pp);
    }
  }
  for (int p = 0; p <= N - 1; p++) {
    for (int q = p + 1; q <= N; q++) {
      int pp;
      if (taka[q][1] - taka[p][0] >= 0) {
        pp = taka[q][1] - taka[p][0];
      } else {
        pp = taka[q][1] - taka[p][0] + 24;
      }
      tmp2 = min(pp, 24 - pp);
    }
  }
  for (int p = 0; p <= N - 1; p++) {
    for (int q = p + 1; q <= N; q++) {
      int pp;
      if (taka[q][0] - taka[p][1] >= 0) {
        pp = taka[q][0] - taka[p][1];
      } else {
        pp = taka[q][0] - taka[p][1] + 24;
      }
      tmp3 = min(pp, 24 - pp);
    }
  }
  for (int p = 0; p <= N - 1; p++) {
    for (int q = p + 1; q <= N; q++) {
      int pp;
      if (taka[q][1] - taka[p][1] >= 0) {
        pp = taka[q][1] - taka[p][1];
      } else {
        pp = taka[q][1] - taka[p][1] + 24;
      }
      tmp4 = min(pp, 24 - pp);
    }
  }
  tmpans = max(max(tmp1, tmp2), max(tmp3, tmp4));
  cout << tmpans << endl;
  return 0;
}
