#include #define rep(i, a, n) for(int i = a; i < n; i++) #define int long long using namespace std; typedef pair P; const int mod = 1000000007; const int INF = 1e18; int d[6] = {500, 100, 50, 10, 5, 1}; int a[6]; bool calc(int n, int k){ if(k == 6) return n == 0; bool res = false; rep(i, 0, a[k] + 1){ res |= calc(n - d[k] * i, k + 1); } return res; } signed main(){ cin.tie(nullptr); ios::sync_with_stdio(false); rep(i, 0, 6) cin >> a[i]; int n; cin >> n; if(calc(n, 0)) cout << "YES" << endl; else cout << "NO" << endl; }