#include <bits/stdc++.h>
using namespace std;
string char_to_str(char c) {
  string tem(1, c);
  return tem;
}
long long max(long long a, long long b) {
  if (a > b) {
    return a;
  }
  return b;
}
long long min(long long a, long long b) {
  if (a < b) {
    return a;
  }
  return b;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long n;
  cin >> n;
  long long p[n];
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
  }
  long long a[5];
  long long b[5];
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
  b[0] = 0;
  b[1] = 0;
  b[2] = 0;
  b[3] = 0;
  b[4] = 0;
  long long prev = 0;
  long long i = 0;
  while (i < n) {
    if (p[i] >= a[4]) {
      long long t = p[i] / a[4];
      p[i] = p[i] - (t * a[4]);
      b[4] = b[4] + t;
    } else if (p[i] >= a[3]) {
      long long t = p[i] / a[3];
      p[i] = p[i] - (t * a[3]);
      b[3] = b[3] + t;
    } else if (p[i] >= a[2]) {
      long long t = p[i] / a[2];
      p[i] = p[i] - (t * a[2]);
      b[2] = b[2] + t;
    } else if (p[i] >= a[1]) {
      long long t = p[i] / a[1];
      p[i] = p[i] - (t * a[1]);
      b[1] = b[1] + t;
    } else if (p[i] >= a[0]) {
      long long t = p[i] / a[0];
      p[i] = p[i] - (t * a[0]);
      b[0] = b[0] + t;
    } else {
      if (i < n - 1) {
        p[i + 1] = p[i + 1] + p[i];
      } else {
        prev = p[i];
      }
      p[i] = 0;
      i++;
    }
  }
  cout << b[0] << " " << b[1] << " " << b[2] << " " << b[3] << " " << b[4]
       << endl;
  cout << prev << endl;
  return 0;
}
