#include <bits/stdc++.h>
using namespace std;
long double EPS = 1e-8;
const long long NMAX = 1111111;
const long long inf = 2e9;
const long long M = 1e9 + 7;
int p[NMAX];
long long ans[NMAX];
pair<long long, long long> a[NMAX];
vector<int> r[NMAX];
vector<int> l[NMAX];
long long t[NMAX * 4];
long long sum[NMAX * 4];
void build(int v, int tl, int tr) {
  if (tl == tr - 1) {
    t[v] = 0;
    sum[v] = 0;
    return;
  }
  int m = (tl + tr) / 2;
  build(2 * v, tl, m);
  build(2 * v + 1, m, tr);
  t[v] = 0;
  sum[v] = 0;
  return;
}
void update(int v, int tl, int tr, int l, int r, long long k, long long data) {
  if (r <= l) return;
  if (r <= tl || tr <= l) return;
  if (l <= tl && tr <= r) {
    t[v] += k;
    sum[v] += data + (tl - l) * k;
    return;
  }
  int m = (tl + tr) / 2;
  update(2 * v, tl, m, l, r, k, data);
  update(2 * v + 1, m, tr, l, r, k, data);
  return;
}
long long get(int v, int tl, int tr, int pos) {
  if (tl == tr - 1) return sum[v];
  int m = (tl + tr) / 2;
  if (pos < m)
    return get(2 * v, tl, m, pos) + sum[v] + t[v] * (pos - tl);
  else
    return get(2 * v + 1, m, tr, pos) + sum[v] + t[v] * (pos - tl);
}
signed main() {
  cin.sync_with_stdio(0);
  cout.sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.precision(40);
  int n;
  cin >> n;
  int q;
  cin >> q;
  for (int i = 1; i <= n; i++) cin >> p[i];
  for (int i = 1; i <= q; i++) cin >> a[i].first;
  for (int i = 1; i <= q; i++) cin >> a[i].second;
  for (int i = 1; i <= q; i++) {
    if (a[i].first == a[i].second)
      ans[i] = 0;
    else {
      r[a[i].second].push_back(i);
      l[a[i].first].push_back(i);
    }
  }
  build(1, 1, n + 1);
  stack<int> st;
  p[0] = n + 1;
  st.push(0);
  for (int i = 1; i <= n; i++) {
    while (p[st.top()] < p[i]) st.pop();
    update(1, 1, n + 1, 1, i, 0, i - st.top() - 1);
    update(1, 1, n + 1, st.top() + 1, i, -1, 0);
    for (int u : r[i]) {
      ans[u] += get(1, 1, n + 1, a[u].first);
    }
    st.push(i);
  }
  st = stack<int>();
  st.push(n + 1);
  p[n + 1] = n + 1;
  build(1, 1, n + 1);
  for (int i = n; i >= 1; i--) {
    while (p[st.top()] < p[i]) st.pop();
    update(1, 1, n + 1, i, st.top(), 1, 0);
    update(1, 1, n + 1, st.top(), n + 1, 0, st.top() - i - 1);
    for (int u : l[i]) {
      ans[u] += get(1, 1, n + 1, a[u].second);
    }
    st.push(i);
  }
  for (int i = 1; i <= q; i++)
    cout << ans[i] + a[i].second - a[i].first + 1 << ' ';
  cout << endl;
  return 0;
}
