#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b, c, d, e, exp, sum = 0;
  long long int p[51] = {0};
  int n, i;
  long long int num[5] = {0};
  cin >> n;
  for (i = 0; i < n; i++) cin >> p[i];
  cin >> a >> b >> c >> d >> e;
  sum = p[0];
  for (i = 1; i <= n; i++) {
    while (sum >= a) {
      if (sum >= e) {
        exp = sum / e;
        sum = sum - (exp * e);
        num[4] += exp;
      } else if (sum >= d) {
        exp = sum / d;
        sum = sum - (exp * d);
        num[3] += exp;
      } else if (sum >= c) {
        exp = sum / c;
        sum = sum - (exp * c);
        num[2] += exp;
      } else if (sum >= b) {
        exp = sum / b;
        sum = sum - (exp * b);
        num[1] += exp;
      } else if (sum >= a) {
        exp = sum / a;
        sum = sum - (exp * a);
        num[0] += exp;
      }
    }
    if (i != n) sum += p[i];
  }
  for (i = 0; i < 5; i++)
    if (i != 4)
      cout << num[i] << " ";
    else
      cout << num[i] << endl;
  cout << sum << endl;
  return 0;
}
