#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, tmp;
  bool ok = 1;
  int ar[5];
  memset(ar, 0, sizeof(ar));
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &tmp);
    tmp /= 25;
    if (!ok) continue;
    if (tmp == 1) {
      ar[1]++;
    } else if (tmp == 2) {
      if (ar[1] > 0) {
        ar[1]--;
        ar[2]++;
      } else
        ok = 0;
    } else if (tmp == 4) {
      if (ar[1] > 0 && ar[2] > 0) {
        ar[1]--;
        ar[2]--;
        ar[4]++;
      } else if (ar[1] > 2) {
        ar[1] -= 3;
        ar[4]++;
      } else
        ok = 0;
    }
  }
  if (ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
