#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a = 0, b = 0, ar[100009];
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> ar[i];
  for (int i = 1; i <= n; i++) {
    if (ar[i] == 25)
      a++;
    else if (ar[i] == 50) {
      a--;
      b++;
    } else if (ar[i] == 100) {
      if (b > 0) {
        a--;
        b--;
      } else
        a -= 3;
    }
    if (a < 0) {
      cout << "NO" << endl;
      return 0;
    }
  }
  if (a >= 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
