#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int ar[n];
  long long int left = 0;
  for (int i = 0; i < n; i++) cin >> ar[i];
  vector<pair<long long int, long long int> > cost(5);
  for (int i = 0; i < 5; i++) {
    cin >> cost[i].first;
    cost[i].second = i;
  }
  long long int ans[5] = {0};
  sort(cost.begin(), cost.end());
  for (int i = 0; i < n; i++) {
    left += ar[i];
    for (int j = 4; j >= 0; j--) {
      long long int buy = left / cost[j].first;
      ans[cost[j].second] += buy;
      left -= (cost[j].first * buy);
    }
  }
  cout << ans[0] << ' ' << ans[1] << ' ' << ans[2] << ' ' << ans[3] << ' '
       << ans[4] << endl;
  cout << left << endl;
  return 0;
}
