#include <bits/stdc++.h>
using namespace std;
int n, k;
int maxnum = -1 << 29;
int number[55][2];
int book[55];
int a[55][55];
int cal(int i, int j) {
  int maxnum = -1 << 29;
  for (int k = 0; k < 2; k++) {
    for (int p = 0; p < 2; p++) {
      int t = number[j][p] - number[i][k];
      t = min(t, 24 - t);
      maxnum = max(maxnum, t);
    }
  }
  return maxnum;
}
int main() {
  cin >> n;
  int maxnum = -1 << 29;
  int minnum = 1 << 29;
  int flag = 1 << 29;
  memset(a, 0, sizeof(a));
  for (int i = 1; i <= n; i++) {
    cin >> book[i];
    a[0][i] = a[i][0] = book[i];
  }
  for (int i = 1; i <= n; i++) {
    number[i][0] = book[i];
    number[i][1] = 24 - book[i];
  }
  if (n == 1) {
    cout << min(number[1][0], number[1][1]) << endl;
    return 0;
  }
  for (int i = 1; i < n; i++) {
    for (int j = i + 1; j <= n; j++) {
      a[i][j] = a[j][i] = cal(i, j);
    }
  }
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j <= n; j++) minnum = min(a[i][j], minnum);
  cout << minnum << endl;
  return 0;
}
