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