#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& a) {
  in >> a.first >> a.second;
  return in;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2> a) {
  out << a.first << " " << a.second;
  return out;
}
template <typename T, typename T1>
T maxs(T& a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T mins(T& a, T1 b) {
  if (b < a) a = b;
  return a;
}
template <typename T>
struct Fenwick {
  vector<T> tree;
  Fenwick(long long n) { tree.resize(n); }
  T query(long long i) {
    pair<long long, long long> sum;
    while (i) {
      sum.first += tree[i].first;
      sum.second += tree[i].second;
      i -= i & (-i);
    }
    return sum;
  }
  void update(long long i, long long n, T val) {
    while (i <= n) {
      tree[i].first += val.first;
      tree[i].second += val.second;
      i += i & (-i);
    }
  }
};
long long solve() {
  long long n, q;
  cin >> n >> q;
  vector<long long> p(n + 1);
  for (long long i = 1; i < n + 1; i++) cin >> p[i];
  stack<pair<long long, long long>> st;
  vector<pair<long long, long long>> l(n + 1), r(n + 1);
  vector<long long> p1(n + 1), p2(n + 1);
  Fenwick<pair<long long, long long>> fn(n + 1);
  for (long long i = 1; i <= n; i++) {
    while (!st.empty() && st.top().first < p[i]) {
      r[st.top().second] = {i - 1, st.top().second};
      st.pop();
    }
    st.push({p[i], i});
  }
  while (!st.empty()) {
    r[st.top().second] = {n, st.top().second};
    st.pop();
  }
  for (long long i = n; i >= 1; i--) {
    while (!st.empty() && st.top().first < p[i]) {
      l[st.top().second] = {i + 1, st.top().second};
      st.pop();
    }
    st.push({p[i], i});
  }
  while (!st.empty()) {
    l[st.top().second] = {1, st.top().second};
    st.pop();
  }
  for (long long i = 1; i <= n; i++) {
    p1[i] += p1[i - 1] + l[i].first;
    p2[i] += p2[i - 1] + r[i].first;
  }
  sort(r.begin(), r.end(), greater<pair<long long, long long>>());
  sort(l.begin(), l.end());
  vector<long long> ans(q);
  vector<pair<long long, pair<long long, long long>>> v(q);
  for (long long i = 0; i < q; i++) {
    cin >> v[i].first;
  }
  for (long long i = 0; i < q; i++) {
    cin >> v[i].second.first;
    v[i].second.second = i;
    ans[i] += p2[v[i].second.first] - p2[v[i].first - 1];
    ans[i] -= p1[v[i].second.first] - p1[v[i].first - 1];
    ans[i] += v[i].second.first - v[i].first + 1;
  }
  sort(v.begin(), v.end());
  long long j = 1;
  for (long long i = 0; i < q; i++) {
    while (j <= n && l[j].first < v[i].first) {
      pair<long long, long long> p = {l[j].first, 1};
      fn.update(l[j].second, n, p);
      j++;
    }
    long long idx = v[i].second.second;
    pair<long long, long long> p = fn.query(v[i].second.first);
    pair<long long, long long> p2 = fn.query(v[i].first - 1);
    p.first -= p2.first, p.second -= p2.second;
    ans[idx] -= p.second * v[i].first - p.first;
  }
  sort(v.begin(), v.end(),
       [&](pair<long long, pair<long long, long long>> p1,
           pair<long long, pair<long long, long long>> p2) {
         return p1.second.first > p2.second.first;
       });
  j = 1;
  fn.tree.clear();
  fn.tree.resize(n + 1);
  for (long long i = 0; i < q; i++) {
    while (j <= n && r[j].first > v[i].second.first) {
      pair<long long, long long> p = {r[j].first, 1};
      fn.update(r[j].second, n, p);
      j++;
    }
    long long idx = v[i].second.second;
    pair<long long, long long> p = fn.query(v[i].second.first);
    pair<long long, long long> p2 = fn.query(v[i].first - 1);
    p.first -= p2.first;
    p.second -= p2.second;
    ans[idx] += p.second * v[i].second.first - p.first;
  }
  for (long long i = 0; i < q; i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
