#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return (b ? gcd(b, a % b) : a); }
bool isPrime(long long n) {
  if (n == 1) return false;
  if (n == 2) return true;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
void solve() {
  long long n;
  cin >> n;
  vector<long long> v(n);
  for (auto &i : v) cin >> i;
  ;
  map<long long, long long> m;
  for (long long i = 0; i < n; i++) {
    if (v[i] == 25) {
      m[v[i]]++;
      continue;
    } else if (v[i] == 50) {
      if (m[25]) {
        m[25]--;
        m[50]++;
      } else {
        cout << "NO" << endl;
        return;
      }
    } else {
      if (m[25] && m[50]) {
        m[25]--;
        m[50]--;
        m[100]++;
      } else if (m[25] >= 3) {
        m[25] -= 3;
        m[100]++;
      } else {
        cout << "NO" << endl;
        return;
      }
    }
  }
  cout << "YES" << endl;
}
int32_t main() {
  ios_base ::sync_with_stdio(false), cin.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
