#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (a[n - 1] != 90) {
    n++;
    a[n - 1] = 90;
  }
  int current = 0;
  int d = -1;
  while (d < n - 1 && a[d + 1] - current <= 15) {
    if (d < n - 1) {
      current = a[d + 1];
    }
    d++;
  }
  cout << (d == n - 1 ? a[n - 1] : current + 15) << endl;
  return 0;
}
