#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long p[n], s = 0, a, b, c, d, e, freq[5] = {0};
  for (int i = 0; i < n; i++) cin >> p[i];
  cin >> a >> b >> c >> d >> e;
  long long j = 0;
  while (j < n) {
    s += p[j];
    j++;
    if (e <= s) {
      freq[4] += (s / e);
      s = s % e;
    }
    if (d <= s) {
      freq[3] += (s / d);
      s = s % d;
    }
    if (c <= s) {
      freq[2] += (s / c);
      s = s % c;
    }
    if (b <= s) {
      freq[1] += (s / b);
      s = s % b;
    }
    if (a <= s) {
      freq[0] += (s / a);
      s = s % a;
    }
  }
  for (int i = 0; i < 5; i++) cout << freq[i] << " ";
  cout << endl;
  cout << s;
  return 0;
}
