#include <bits/stdc++.h>
using namespace std;
bool sort1(pair<long long, long long> P1, pair<long long, long long> P2) {
  return P1.first > P2.first;
}
int main() {
  int n;
  cin >> n;
  long long P[n + 5], X;
  for (int i = 0; i < n; i++) cin >> P[i];
  vector<pair<long long, long long>> V;
  for (int i = 0; i < 5; i++) {
    cin >> X;
    V.push_back(make_pair(X, i));
  }
  sort(V.begin(), V.end(), sort1);
  long long carry = 0;
  long long A[5];
  memset(A, 0, sizeof(A));
  for (int i = 0; i < n; i++) {
    long long Temp = P[i] + carry;
    A[V[0].second] += (Temp / V[0].first);
    Temp = Temp % V[0].first;
    A[V[1].second] += Temp / V[1].first;
    Temp = Temp % V[1].first;
    A[V[2].second] += Temp / V[2].first;
    Temp = Temp % V[2].first;
    A[V[3].second] += Temp / V[3].first;
    Temp = Temp % V[3].first;
    A[V[4].second] += Temp / V[4].first;
    Temp = Temp % V[4].first;
    carry = Temp;
  }
  cout << A[0] << " " << A[1] << " " << A[2] << " " << A[3] << " " << A[4]
       << endl;
  cout << carry;
  return 0;
}
