cin >> n >> m; for (int i = 1; i <= n; ++i) cin >> a[i]; stack<int> S; S.push(0); a[0] = a[n + 1] = n + 1; for (int i = 1; i <= n + 1; ++i) { while (!S.empty() && a[i] > a[S.top()]) r[S.top()] = i, S.pop(); l[i] = S.top(); S.push(i); } for (int i = 1; i <= m; ++i) cin >> Q[i].first; for (int i = 1; i <= m; ++i) cin >> Q[i].second; for (int i = 1; i <= m; ++i) { A[Q[i].first - 1].push_back({ -1, Q[i].first, Q[i].second, i }); A[Q[i].second].push_back({ 1, Q[i].first, Q[i].second, i }); } for (int i = 1; i <= n; ++i) { Bit.update(l[i] + 1, r[i] - 1, 1); for (auto t : A[i]) ans[t.id] += t.type * Bit.query(t.l, t.r); } for (int i = 1; i <= m; ++i) cout << ans[i] << " \n"[i == m]; return0; }