#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000000 + 500;
const long long LLMAX = 0x7fffffffffffffffLL;
const long long LLMIN = 0x8000000000000000LL;
const int INF = 0x7fffffff;
const int IMIN = 0x80000000;
const double e = 2.718281828;
const double PI = acos(-1.0);
int a[2];
int main() {
  int n;
  scanf("%d", &n);
  while (n--) {
    int x;
    scanf("%d", &x);
    if (x == 25)
      a[0]++;
    else if (x == 50)
      a[1]++;
    if (x == 50) {
      if (a[0] < 1) {
        puts("NO");
        return 0;
      } else
        a[0]--;
    }
    if (x == 100) {
      if (a[1] >= 1 && a[0] >= 1) {
        a[0]--;
        a[1]--;
      } else if (a[0] >= 3) {
        a[0] -= 3;
      } else {
        puts("NO");
        return 0;
      }
    }
  }
  puts("YES");
  return 0;
}
