#include <bits/stdc++.h>
using namespace std;
const int NMAX = 1000100;
int l[NMAX], r[NMAX], a[NMAX];
long long ans[NMAX];
vector<int> lh[NMAX], rh[NMAX];
long long n, q;
struct segtree {
  vector<long long> t, d;
  int h, n;
  segtree() {}
  segtree(int sz) {
    h = 32 - __builtin_clz(sz);
    n = 1 << h;
    t = vector<long long>(n << 1, 0);
    d = vector<long long>(n << 1, 0);
  }
  void apply(int x, long long v) {
    d[x] += v;
    t[x] += v * (1 << (h - 31 + __builtin_clz(x)));
  }
  void pushh(int x) {
    if (d[x]) {
      apply(x << 1, d[x]);
      apply(x << 1 | 1, d[x]);
      d[x] = 0;
    }
  }
  void push(int i) {
    i += n;
    for (int l = h; l > 0; --l) {
      pushh(i >> l);
    }
  }
  void pulll(int x) {
    t[x] =
        t[x << 1] + t[x << 1 | 1] + d[x] * (1 << (h - 31 + __builtin_clz(x)));
  }
  void set(int l, int r) {
    if (l >= r) return;
    push(l);
    push(r - 1);
    bool cl = 0, cr = 0;
    for (l += n, r += n; l < r; l /= 2, r /= 2) {
      if (cl) {
        pulll(l - 1);
      }
      if (cr) {
        pulll(r);
      }
      if (l % 2) {
        apply(l++, 1);
        cl = 1;
      }
      if (r % 2) {
        apply(--r, 1);
        cr = 1;
      }
    }
    for (--l; r > 0; l /= 2, r /= 2) {
      if (cl) pulll(l);
      if (cr && (!cl || r != l)) pulll(r);
    }
  }
  long long query(int l, int r) {
    push(l);
    push(r - 1);
    long long ans = 0;
    for (l += n, r += n; l < r; l /= 2, r /= 2) {
      if (l % 2) {
        ans += t[l++];
      }
      if (r % 2) {
        ans += t[--r];
      }
    }
    return ans;
  }
};
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n >> q;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (int i = 1; i <= q; ++i) {
    cin >> l[i];
    lh[l[i]].push_back(i);
  }
  for (int i = 1; i <= q; ++i) {
    cin >> r[i];
    rh[r[i]].push_back(i);
  }
  segtree st(n + 2);
  a[0] = NMAX;
  stack<int> s;
  s.push(0);
  for (int i = 1; i <= n; ++i) {
    while (!s.empty() && a[s.top()] < a[i]) s.pop();
    st.set(s.top() + 1, i);
    for (auto& j : rh[i]) {
      ans[j] += st.query(l[j], i);
    }
    s.push(i);
  }
  st = segtree(n + 1);
  s.pop();
  a[n + 1] = NMAX;
  s.push(n + 1);
  for (int i = n; i > 0; --i) {
    while (!s.empty() && a[s.top()] < a[i]) s.pop();
    st.set(i + 1, s.top());
    for (auto& j : lh[i]) {
      ans[j] += st.query(i, r[j] + 1);
    }
    s.push(i);
  }
  for (int i = 1; i <= q; ++i) {
    cout << ans[i] + r[i] - l[i] + 1 << " ";
  }
  cout << endl;
  return 0;
}
