#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct dsu {
vector<int> pa, sz, active;
int n;
ll ans = 0;
dsu(int n) : n(n), pa(n), sz(n, 1), active(n, 0) {
iota(pa.begin(), pa.end(), 0);
}
ll calc(ll i){return i * (i + 1) / 2;}
int f(int i){
if (pa[i] == i) return i;
return pa[i] = f(pa[i]);
}
bool unite(int u, int v){
int fu = f(u), fv = f(v);
if (fu == fv) return false;
if (sz[fu] > sz[fv]) swap(fu, fv);
ans -= calc(sz[fu]);
ans -= calc(sz[fv]);
pa[fu] = fv;
sz[fv] += sz[fu];
sz[fu] = 0;
ans += calc(sz[fv]);
return true;
}
void act(int i){
active[i] = true;
ans += 1;
if (i > 0 && active[i - 1]) unite(i, i - 1);
if (i < n - 1 && active[i + 1]) unite(i, i + 1);
}
};
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, q;
cin >> n >> q;
vector<pair<int, int>> v(n);
for (int i = 0;i < n;i++){
cin >> v[i].first;
v[i].second = i;
}
vector<pair<int, int>> query(q);
for (int i = 0;i < q;i++){
cin >> query[i].first;
query[i].second = i;
}
sort(v.begin(), v.end());
sort(query.begin(), query.end());
int idx = 0;
dsu g(n);
vector<ll> ans(q);
for (auto [h, id]:query){
while (idx < n && h >= v[idx].first){
g.act(v[idx].second);
idx++;
}
ans[id] = g.ans;
}
for (auto e:ans) cout << e << '\n';
}