#include <bits/stdc++.h>
using namespace std;
int n, m, ql[1000005], qr[1000005], a[1000005], L[1000005], stk[1000005], top;
long long ans[1000005];
vector<int> Q[1000005], G[1000005];
struct BIT {
  long long arr[1000005];
  void clear() { memset(arr, 0, sizeof arr); }
  void upd(int i, int d) {
    for (; i <= n; i += i & -i) arr[i] += d;
  }
  long long qsum(int i) {
    long long s = 0;
    for (; i; i -= i & -i) s += arr[i];
    return s;
  }
  long long ask(int l, int r) { return qsum(r) - qsum(l - 1); }
} T[2];
void solve() {
  T[0].clear(), T[1].clear(), top = 0;
  for (int i = 1; i <= n; i++) Q[i].clear(), G[i].clear();
  for (int i = 1; i <= m; i++)
    ans[i] += 1ll * (ql[i] + qr[i]) * (qr[i] - ql[i] + 1) / 2,
        Q[ql[i]].push_back(i);
  for (int i = 1; i <= n; i++) {
    while (top && a[stk[top]] < a[i]) top--;
    L[i] = stk[top] + 1, stk[++top] = i;
    T[0].upd(i, L[i]), G[L[i]].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    for (int x : Q[i]) ans[x] -= T[0].ask(i, qr[x]) + T[1].ask(i, qr[x]) * i;
    for (int x : G[i]) T[0].upd(x, -L[x]), T[1].upd(x, 1);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++) scanf("%d", &ql[i]);
  for (int i = 1; i <= m; i++) scanf("%d", &qr[i]);
  solve();
  reverse(a + 1, a + 1 + n);
  for (int i = 1; i <= m; i++)
    ql[i] = n - ql[i] + 1, qr[i] = n - qr[i] + 1, swap(ql[i], qr[i]);
  solve();
  for (int i = 1; i <= m; i++)
    printf("%I64d%c", ans[i] + qr[i] - ql[i] + 1, i == m ? 10 : 32);
}
