#pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include using namespace std; using P = pair; const long long LM = 1LL << 60; int main() { cin.tie(0); ios::sync_with_stdio(0); int n, q; cin >> n >> q; vector a(n); int sum = 0; for (int i = 0; i < n; ++i) { cin >> a[i]; sum += a[i]; } vector cnt(n); for (int i = 0; i < q; ++i) { int x; cin >> x; ++cnt[x]; } vector c(q + 1); for (int i = 0; i <= q; ++i) { ++c[cnt[i]]; } int freq = -1, ma = 0; for (int i = 0; i <= q; ++i) { if (ma < c[i]) { ma = c[i]; freq = i; } } vector b(n); for (int i = 0; i < n; ++i) { b[i] = freq * sum; cnt[i] -= freq; } for (int i = 0; i < n; ++i) { if (cnt[i] == 0) continue; for (int j = 0; j < n; ++j) { b[j] += cnt[i] * a[i + j < n ? i + j : i + j - n]; } } for (int i = 0; i < n; ++i) { cout << b[i] << (i < n - 1 ? ' ' : '\n'); } return 0; }