#include <bits/stdc++.h>
using namespace std;
long long ans[1000006];
struct pp {
  long long l, r, sum, tag;
} tr[4000006];
int l[1000006], r[1000006], a[1000006];
struct ppp {
  int l, r, v;
} c[1000006];
bool cmpr(ppp i, ppp j) { return i.r < j.r; }
bool cmpl(ppp i, ppp j) { return i.l > j.l; }
void up(long long i) { tr[i].sum = tr[i * 2].sum + tr[i * 2 + 1].sum; }
void buildtree(long long i, long long l, long long r) {
  tr[i].l = l;
  tr[i].r = r;
  tr[i].tag = 0;
  if (l == r) {
    tr[i].sum = 0;
    return;
  }
  long long m = (l + r) / 2;
  buildtree(i * 2, l, m);
  buildtree(i * 2 + 1, m + 1, r);
  up(i);
}
void dn(long long i) {
  if (!tr[i].tag) return;
  long long v = tr[i].tag;
  tr[i].tag = 0;
  tr[i * 2].tag += v;
  tr[i * 2 + 1].tag += v;
  tr[i * 2].sum += v * (tr[i * 2].r - tr[i * 2].l + 1);
  tr[i * 2 + 1].sum += v * (tr[i * 2 + 1].r - tr[i * 2 + 1].l + 1);
}
void update(long long i, long long l, long long r, long long k) {
  if (tr[i].l >= l && tr[i].r <= r) {
    tr[i].sum += k * (tr[i].r - tr[i].l + 1);
    tr[i].tag += k;
    return;
  }
  dn(i);
  long long m = (tr[i].l + tr[i].r) / 2;
  if (l <= m) update(i * 2, l, r, k);
  if (r > m) update(i * 2 + 1, l, r, k);
  up(i);
}
long long query(long long i, long long l, long long r) {
  if (tr[i].l >= l && tr[i].r <= r) {
    return tr[i].sum;
  }
  dn(i);
  long long m = (tr[i].l + tr[i].r) / 2, ans = 0;
  if (l <= m) ans += query(i * 2, l, r);
  if (r > m) ans += query(i * 2 + 1, l, r);
  return ans;
}
int main() {
  long long n, q, w = 1;
  scanf("%lld%lld", &n, &q);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  a[0] = 2e9;
  a[n + 1] = 2e9;
  for (long long i = 1; i <= q; i++) {
    scanf("%lld", &c[i].l);
  }
  for (long long i = 1; i <= q; i++) {
    scanf("%lld", &c[i].r);
    c[i].v = i;
  }
  for (long long i = 1; i <= n; i++) {
    l[i] = i - 1;
    while (a[l[i]] < a[i]) l[i] = l[l[i]];
  }
  for (long long i = n; i >= 1; i--) {
    r[i] = i + 1;
    while (a[r[i]] < a[i]) r[i] = r[r[i]];
  }
  for (long long i = 1; i <= n; i++) {
    l[i]++;
    r[i]--;
  }
  buildtree(1, 1, n);
  sort(c + 1, c + 1 + q, cmpr);
  for (long long i = 1; i <= q; i++) {
    while (w <= c[i].r) {
      update(1, l[w], w, 1);
      w++;
    }
    ans[c[i].v] += query(1, c[i].l, c[i].r);
  }
  buildtree(1, 1, n);
  w = n;
  sort(c + 1, c + 1 + q, cmpl);
  for (long long i = 1; i <= q; i++) {
    while (w >= c[i].l) {
      update(1, w, r[w], 1);
      w--;
    }
    ans[c[i].v] += query(1, c[i].l, c[i].r) - (c[i].r - c[i].l + 1);
  }
  for (long long i = 1; i <= q; i++) {
    printf("%lld ", ans[i]);
  }
  cout << endl;
}
