/* GCC */
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <set>
#include <vector>
#include <map>

using namespace std;

int n, m;
vector<int> A;

int Q(int X, int k)
{
    return (A[k] <= X) ? A[k] : X;
}

int main()
{
    freopen("pelmeni.in", "r", stdin);
    freopen("pelmeni.out", "w", stdout);

    scanf("%d %d\n", &n, &m);
    A.resize(n);
    for (int k = 0; k < n; k++)
        scanf("%d", &A[k]);

    unsigned long long w = 0;
    int y;
    scanf("%d", &y);
    for (int j = 0; j < n; j++)
        w += Q(y, j);

    cout << w;

    for (int k = 1; k < m; k++) {
        unsigned long long w = 0;
        int y;
        scanf("%d", &y);
        for (int j = 0; j < n; j++)
            w += Q(y, j);

        cout << " " << w;
    }

    cout << endl;

    return 0;
}
