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