/* GCC */

#define maxn 100000
#define maxm 100000
#define base 10000

#include <stdio.h>

using namespace std;

int state[maxn];
bool first = true;
int ans[4], sum[4];

inline void multlong(int a, int b) //ans = x * (n - termin)
{
    int a0, b0, a1, b1;
    a0 = a / base;
    b0 = b / base;
    a1 = a % base;
    b1 = b % base;
    ans[1] = a0 * b0;
    ans[2] = a0 * b1 + a1 * b0;
    ans[3] = a1 * b1;
    if (ans[3] > base - 1)
    {
        ans[2] += ans[3] / base;
        ans[3] %= base;
    }
    if (ans[2] > base - 1)
    {
        ans[1] += ans[2] / base;
        ans[2] %= base;
    }
    if (ans[1] > base - 1)
    {
        ans[0] += ans[1] / base;
        ans[1] %= base;
    }
}

inline void sumlong (int x) //sum += state[termin]
{
    sum[3] += x;
    if (sum[3] > base - 1)
    {
        sum[2] += sum[3] / base;
        sum[3] %= base;
    }
    if (sum[2] > base - 1)
    {
        sum[1] += sum[2] / base;
        sum[2] %= base;
    }
    if (sum[1] > base - 1)
    {
        sum[0] += sum[1] / base;
        sum[1] %= base;
    }
}

inline void sumans() //ans += sum
{
    ans[0] += sum[0];
    ans[1] += sum[1];
    ans[2] += sum[2];
    ans[3] += sum[3];
    if (ans[3] > base - 1)
    {
        ans[2] += ans[3] / base;
        ans[3] %= base;
    }
    if (ans[2] > base - 1)
    {
        ans[1] += ans[2] / base;
        ans[2] %= base;
    }
    if (ans[1] > base - 1)
    {
        ans[0] += ans[1] / base;
        ans[1] %= base;
    }
}

inline void determine(int x, int& termin, int n)
{
    while (state[termin] <= x && termin < n)
    {
        sumlong(state[termin]);
        termin++;
    }
    for (int i = 0; i < 4; i++)
        ans[i] = 0;
    multlong(x, n - termin);
    sumans();
}

inline void printans()
{
    if (first)
        first = false;
    else
        printf(" ");
    int k = 0;
    while (ans[k] == 0)
        k++;
    printf("%d", ans[k]);
    k++;
    for (int i = k; i < 4; i++)
    {
        if (ans[i] < 1000)
            printf("0");
        if (ans[i] < 100)
            printf("0");
        if (ans[i] < 10)
            printf("0");
        printf("%d", ans[i]);
    }
}

int main()
{
    freopen("pelmeni.in", "r", stdin);
    freopen("pelmeni.out", "w", stdout);
    int n, m, penult = 0, termin = 0;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++)
        scanf("%d", &state[i]);
    for (int i = 0; i < m; i++)
    {
        int b;
        scanf("%d", &b);
        if (b != penult)
            determine(b, termin, n);
        printans();
        penult = b;
    }
    printf("\n");
    return 0;
}
