#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  int ruble[3] = {0}, n, temp;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    switch (temp) {
      case 25:
        ruble[0]++;
        break;
      case 50:
        ruble[1]++;
        ruble[0]--;
        break;
      case 100:
        ruble[2]++;
        if (ruble[1] > 0)
          ruble[1]--, ruble[0]--;
        else
          ruble[0] -= 3;
    }
    if (ruble[0] < 0) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
