#include <bits/stdc++.h>
using namespace std;
int n, a[1000000], s = 0;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++)
    if (n == 1) {
      cout << "0";
      return 0;
    } else
      s = 24 - a[i] - a[i - 1];
  cout << s;
}
