#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int a[N], L[N], tot, R[N], Stack[N], n, m;
long long Ans[N];
struct Ask {
  int l, r, from;
} A[N];
inline int cmp1(Ask x, Ask y) { return x.l > y.l; }
inline int cmp2(Ask x, Ask y) { return x.r < y.r; }
struct segTree {
  struct Tree {
    int l, r;
    long long num, flag;
  } T[N * 4];
  inline void build(int x, int l, int r) {
    T[x].l = l;
    T[x].r = r;
    T[x].flag = T[x].num = 0;
    if (l == r) return;
    int mid = (l + r) / 2;
    build(x * 2, l, mid);
    build(x * 2 + 1, mid + 1, r);
  }
  inline void down(int x) {
    if (!T[x].flag) return;
    T[x * 2].num += T[x].flag * (T[x * 2].r - T[x * 2].l + 1);
    T[x * 2 + 1].num += T[x].flag * (T[x * 2 + 1].r - T[x * 2 + 1].l + 1);
    T[x * 2].flag += T[x].flag;
    T[x * 2 + 1].flag += T[x].flag;
    T[x].flag = 0;
  }
  inline void insert(int x, int l, int r, int z) {
    if (T[x].l > r || l > T[x].r) return;
    if (T[x].l >= l && T[x].r <= r) {
      T[x].num += z * (T[x].r - T[x].l + 1);
      T[x].flag += z;
      return;
    }
    down(x);
    insert(x * 2, l, r, z);
    insert(x * 2 + 1, l, r, z);
    T[x].num = T[x * 2].num + T[x * 2 + 1].num;
  }
  inline long long find(int x, int y) {
    if (T[x].l == T[x].r) return T[x].num;
    down(x);
    int mid = (T[x].l + T[x].r) / 2;
    if (y <= mid) return find(x * 2, y);
    return find(x * 2 + 1, y);
  }
} T1, T2;
signed main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++) A[i].from = i;
  for (int i = 1; i <= m; i++) scanf("%d", &A[i].l);
  for (int i = 1; i <= m; i++) scanf("%d", &A[i].r);
  for (int i = 1; i <= m; i++) Ans[i] = A[i].r - A[i].l + 1;
  a[0] = a[n + 1] = n + 1;
  Stack[++tot] = 0;
  for (int i = 1; i <= n; i++) {
    while (a[i] > a[Stack[tot]]) tot--;
    L[i] = Stack[tot] + 1;
    Stack[++tot] = i;
  }
  Stack[tot = 1] = n + 1;
  for (int i = n; i; i--) {
    while (a[i] > a[Stack[tot]]) tot--;
    R[i] = Stack[tot] - 1;
    Stack[++tot] = i;
  }
  T1.build(1, 1, n);
  T2.build(1, 1, n);
  sort(A + 1, A + m + 1, cmp2);
  for (int i = 1, j = 1; i <= n; i++) {
    T1.insert(1, 1, L[i] - 1, -L[i]);
    T2.insert(1, L[i], i, -1);
    while (j <= m && A[j].r == i) {
      Ans[A[j].from] +=
          T1.find(1, A[j].l) + (long long)T2.find(1, A[j].l) * A[j].l;
      j++;
    }
  }
  T1.build(1, 1, n);
  T2.build(1, 1, n);
  sort(A + 1, A + m + 1, cmp1);
  for (int i = n, j = 1; i; i--) {
    T1.insert(1, R[i] + 1, n, R[i]);
    T2.insert(1, i, R[i], 1);
    while (j <= m && A[j].l == i) {
      Ans[A[j].from] +=
          T1.find(1, A[j].r) + (long long)T2.find(1, A[j].r) * A[j].r;
      j++;
    }
  }
  for (int i = 1; i <= m; i++) printf("%lld ", Ans[i]);
  return 0;
}
