#include <bits/stdc++.h>
using namespace std;
const long long mod = 1073741824;
const long long M = 1e6 + 5;
const double pi = acos(-1.);
const long long dx[] = {1, 0, -1, 0, -1, -1, 1, 1};
const long long dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
long long a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, w, x,
    y, z, maxi, mini, ans, mid, low, high, total, sum;
string s1, s2;
int main() {
  cin >> n;
  map<long long, long long> m;
  vector<long long> a(n);
  for (i = 0; i < n; i++) cin >> a[i];
  ;
  for (i = 0; i < n; i++) {
    x = a[i];
    m[x]++;
    if (x > 25) {
      if (x == 100) {
        if (m[25] >= 1 && m[50] >= 1) {
          m[25] -= 1;
          m[50] -= 1;
        } else if (m[25] >= 3)
          m[25] -= 3;
        else {
          cout << "NO";
          return 0;
        }
      } else if (x == 50) {
        if (m[25] >= 1) {
          m[25] -= 1;
        } else {
          cout << "NO";
          return 0;
        }
      }
    }
  }
  cout << "YES";
}
