#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int d[100] = {0};
  for (int i = 1; i <= n; i++) cin >> d[i];
  int ans = *min_element(d + 1, d + n + 1);
  int wz[100] = {0};
  wz[1] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (wz[j] == 0) {
        if (abs(d[i] - d[j]) > abs(d[i] - (24 - d[j]))) {
          wz[j] = wz[i];
          ans = min(ans, abs(d[i] - d[j]));
        } else {
          wz[j] = -wz[i];
          ans = min(ans, abs(d[i] - (24 - d[j])));
        }
      } else {
        if (wz[i] + wz[j] == 0) {
          int tmp1 = abs(d[i] - (24 - d[j]));
          int tmp2 = abs(d[i] - d[j]);
          if (tmp1 >= tmp2) {
            ans = min(ans, tmp1);
            continue;
          }
          if (ans >= tmp2) {
            continue;
          }
          int tmp3 = 100;
          for (int k = 1; k < i; k++) {
            if (wz[k] + wz[j]) {
              tmp3 = min(tmp3, abs(d[k] - d[j]));
            } else
              tmp3 = min(tmp3, abs(d[k] - (24 - d[j])));
          }
          if (tmp3 >= tmp2) {
            ans = min(ans, tmp2);
            wz[j] = -wz[j];
          } else
            ans = min(ans, tmp1);
        } else {
          int tmp1 = abs(d[i] - d[j]);
          int tmp2 = abs(d[i] - (24 - d[j]));
          if (tmp1 >= tmp2) {
            ans = min(ans, tmp1);
            continue;
          }
          if (ans >= tmp2) {
            continue;
          }
          int tmp3 = 100;
          for (int k = 1; k < i; k++) {
            if (wz[k] + wz[j]) {
              tmp3 = min(tmp3, abs(d[k] - d[j]));
            } else
              tmp3 = min(tmp3, abs(d[k] - (24 - d[j])));
          }
          if (tmp3 >= tmp2) {
            ans = min(ans, tmp2);
            wz[j] = -wz[j];
          } else
            ans = min(ans, tmp1);
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
