#include <bits/stdc++.h>
using namespace std;
int vx[] = {0, 1, 0, -1};
int vy[] = {1, 0, -1, 0};
int dx[] = {1, 0, -1, 1, -1, 1, 0, -1};
int dy[] = {1, 1, 1, 0, 0, -1, -1, -1};
const long long mod = 1e9 + 7;
const int MAX_N = 300;
int main() {
  int n;
  int ans = 0;
  cin >> n;
  int d[n + 1];
  int min_id = 0;
  d[0] = 0;
  for (int i = 1; i < n + 1; i++) {
    cin >> d[i];
  }
  if (n >= 22)
    ans = 0;
  else {
    for (int i = 0; i < (1 << n); i++) {
      int min_time = 12;
      int time[n + 1];
      time[0] = 0;
      for (int j = 0; j < n; j++) {
        if (((i >> j) & 1) == 1)
          time[j + 1] = 24 - d[j + 1];
        else
          time[j + 1] = d[j + 1];
      }
      for (int j = 0; j < n + 1; j++) {
        for (int k = j + 1; k < n + 1; k++) {
          min_time = min(min_time, min(24 - abs(time[j] - time[k]),
                                       abs(time[j] - time[k])));
        }
      }
      ans = max(ans, min_time);
    }
  }
  cout << ans << endl;
  return 0;
}
