#include <bits/stdc++.h>
using namespace std;
int res = 0;
int get(int x) {
return x * (x - 1) / 2;
}
struct DSU {
vector<int> p, sz;
DSU(int n) {
p.assign(n + 1, -1);
sz.assign(n + 1, 1);
}
int root(int x) { return (p[x] == -1 ? x : (p[x] = root(p[x]))); }
bool link(int x, int y) {
x = root(x); y = root(y);
if (x == y) return false;
p[y] = x;
res -= get(sz[x]);
res -= get(sz[y]);
sz[x] += sz[y];
res += get(sz[x]);
return true;
}
};
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, q;
cin >> n >> q;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<array<int, 2>> b;
for (int i = 0; i < n - 1; i++) {
b.push_back({max(a[i], a[i + 1]), i});
}
ranges::sort(b);
vector<array<int, 2>> y(q);
for (int i = 0; i < q; i++) {
cin >> y[i][0];
y[i][1] = i;
}
ranges::sort(y, [&](auto x, auto y) {
return x[0] < y[0];
});
auto c = a;
ranges::sort(c);
DSU dsu(n + 1);
int pos = 0;
vector<int> ans(q);
for (auto [x, id] : y) {
while (pos < n - 1 && b[pos][0] <= x) {
dsu.link(b[pos][1], b[pos][1] + 1);
pos++;
}
int single = ranges::upper_bound(c, x) - c.begin();
ans[id] = res + single;
}
for (int i = 0; i < q; i++) {
cout << ans[i] << '\n';
}
return 0;
}