#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:40000000")
using namespace std;
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int mod = 1000000007;
const int MAXN = 200 * 200;
int a[111];
int n;
int main() {
  cin >> n;
  bool p = 1;
  for (int(i) = (0); (i) < (n); ++(i)) {
    int x;
    cin >> x;
    a[x]++;
    if (x == 25) continue;
    if (x == 50) {
      a[25]--;
      if (a[25] < 0) p = 0;
    }
    if (x == 100) {
      if (a[50] && a[25]) {
        a[50]--;
        a[25]--;
      } else {
        a[25] -= 3;
        if (a[25] < 0) p = 0;
      }
    }
  }
  if (p)
    cout << "YES" << endl;
  else
    cout << "NO";
  return 0;
}
