#include <bits/stdc++.h>
using namespace std;
string binal(int k) {
  string res;
  for (int i = 0, i_len = (23); i < i_len; ++i) {
    res += char('0' + k % 2);
    k /= 2;
  }
  return res;
}
int main() {
  int N;
  cin >> N;
  vector<int> D(N);
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    cin >> D[i];
    if (D[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  vector<bool> dp = vector<bool>(1 << 24, false);
  dp[0] = true;
  for (int i = 0, i_len = (N); i < i_len; ++i)
    for (int j = (1 << 24) - 1; j >= 0; --j) {
      if (dp[j]) {
        dp[j] = false;
        if (!(j >> D[i] & 1)) dp[j ^ (1 << D[i])] = true;
        if (!(j >> (24 - D[i]) & 1)) dp[j ^ (1 << (24 - D[i]))] = true;
      }
    }
  int ans = 0;
  for (int i = 0, i_len = (1 << 24); i < i_len; ++i)
    if (dp[i]) {
      int s = 23, tmp = 1;
      for (int j = 0, j_len = (23); j < j_len; ++j) {
        if (i >> j & 1)
          s = min(s, tmp), tmp = 1;
        else
          tmp++;
      }
      ans = max(ans, s);
    }
  cout << ans << endl;
}
