#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n], tf = 0, fi = 0, hu = 0, flag = 1;
  for (int j = 0; j < n; j++) {
    cin >> arr[j];
    if (arr[j] == 25) {
      tf++;
    } else if (arr[j] == 50) {
      fi++;
      tf--;
      if (tf < 0 || fi < 0 || hu < 0) flag = 0;
    } else if (arr[j] == 100) {
      hu++;
      if (fi >= 1) {
        fi--;
        tf--;
      } else if (fi < 1) {
        tf -= 3;
      }
      if (tf < 0 || fi < 0 || hu < 0) flag = 0;
    }
  }
  if (flag == 1) {
    cout << "YES";
  } else
    cout << "NO";
}
