#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     long long int arr[100];     for (int i = 0; i < n; i++) cin >> arr[i];     long long int cnt[5];     long long int p[5];     for (int i = 0; i < 5; i++) cin >> p[i];     long long int min = 1000000009;     for (int i = 0; i < 5; i++)       if (p[i] < min) min = p[i];     for (int i = 0; i < 5; i++) cnt[i] = 0;     long long int ps = 0;     for (int i = 0; i < n; i++) {       ps = ps + arr[i];       while (ps >= min) {         long long int pp;         for (int j = 4; j >= 0; j--) {           if (ps < min) break;           pp = ps / p[j];           ps = ps - pp * p[j];           cnt[j] += pp;         }       }     }     for (int i = 0; i < 5; i++) cout << cnt[i] <<    ;     cout <<   n  << ps << endl;     return 0;   }   