#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N;
int D[100];
int dp[100][30][30][30];
int solve(int i, int l, int r, int mn) {
  int &res = dp[i][l][r][mn];
  if (res != -1) {
    return res;
  }
  if (i >= N) {
    return res = mn;
  }
  res = max(res, solve(i + 1, D[i], r, min({mn, D[i] - l, r - D[i]})));
  res = max(res, solve(i + 1, l, 24 - D[i], min({mn, r - D[i], D[i] - l})));
  return res;
}
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> D[i];
    D[i] = min(D[i], 24 - D[i]);
  }
  sort(D, D + N);
  memset(dp, -1, sizeof(dp));
  cout << solve(0, 0, 24, 24) << endl;
  return 0;
}
