#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1 << 20;
long long tree[2 * MAX_N];
long long sum[2 * MAX_N];
int cnt[2 * MAX_N];
int pos[2 * MAX_N];
vector<int> vals[2 * MAX_N];
long long get(int node, int low, int high, int nlow, int nhigh, int t) {
  if (nhigh < low || nlow > high) return 0;
  if (low >= nlow && high <= nhigh) {
    if (t == -1) {
      if (pos[node] == -2) pos[node] = 0;
      while (pos[node] < vals[node].size() && vals[node][pos[node]] < nlow) {
        sum[node] += vals[node][pos[node]] * -1;
        ++cnt[node];
        ++pos[node];
      }
      return tree[node] - sum[node] - (long long)cnt[node] * nlow;
    } else {
      if (pos[node] == -2) pos[node] = vals[node].size() - 1;
      while (pos[node] >= 0 && vals[node][pos[node]] >= nhigh) {
        sum[node] += vals[node][pos[node]];
        ++cnt[node];
        --pos[node];
      }
      return sum[node] - (long long)cnt[node] * nhigh;
    }
  }
  int mid = (low + high) / 2;
  long long ret = 0;
  ret += get(node * 2 + 1, low, mid, nlow, nhigh, t);
  ret += get(node * 2 + 2, mid + 1, high, nlow, nhigh, t);
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  vector<int> l(n);
  vector<int> r(n);
  for (auto& x : a) cin >> x;
  vector<int> stk;
  stk.clear();
  for (int i = 0; i < n; ++i) {
    while (stk.size() > 0 && a[stk.back()] < a[i]) stk.pop_back();
    if (stk.size() == 0)
      l[i] = 0;
    else
      l[i] = stk.back() + 1;
    stk.push_back(i);
  }
  stk.clear();
  for (int i = n - 1; i >= 0; --i) {
    while (stk.size() > 0 && a[stk.back()] < a[i]) stk.pop_back();
    if (stk.size() == 0)
      r[i] = n - 1;
    else
      r[i] = stk.back() - 1;
    stk.push_back(i);
  }
  for (int i = 0; i < n; ++i) {
    tree[MAX_N - 1 + i] = r[i] - l[i] + 1;
    vals[MAX_N - 1 + i].push_back(l[i]);
  }
  for (int i = MAX_N - 2; i >= 0; --i) {
    tree[i] = tree[2 * i + 1] + tree[2 * i + 2];
    vals[i].resize(vals[2 * i + 1].size() + vals[2 * i + 2].size());
    int p1 = 0;
    int p2 = 0;
    int nxt = 0;
    while (p1 < vals[2 * i + 1].size() || p2 < vals[2 * i + 2].size()) {
      if (p1 == vals[2 * i + 1].size()) {
        vals[i][nxt++] = vals[2 * i + 2][p2++];
      } else if (p2 == vals[2 * i + 2].size()) {
        vals[i][nxt++] = vals[2 * i + 1][p1++];
      } else {
        if (vals[2 * i + 1][p1] < vals[2 * i + 2][p2]) {
          vals[i][nxt++] = vals[2 * i + 1][p1++];
        } else {
          vals[i][nxt++] = vals[2 * i + 2][p2++];
        }
      }
    }
  }
  vector<pair<pair<int, int>, int>> inters(q);
  vector<long long> res(q, 0);
  for (int i = 0; i < q; ++i) {
    cin >> inters[i].first.first;
    inters[i].first.first--;
  }
  for (int i = 0; i < q; ++i) {
    cin >> inters[i].first.second;
    inters[i].first.second--;
  }
  for (int i = 0; i < q; ++i) inters[i].second = i;
  for (int i = 0; i < 2 * MAX_N; ++i) {
    sum[i] = 0;
    cnt[i] = 0;
    pos[i] = -2;
  }
  sort(inters.begin(), inters.end());
  for (int i = 0; i < q; ++i) {
    res[inters[i].second] +=
        get(0, 0, MAX_N - 1, inters[i].first.first, inters[i].first.second, -1);
  }
  for (int i = 0; i < 2 * MAX_N; ++i) {
    sum[i] = 0;
    cnt[i] = 0;
    pos[i] = -2;
  }
  for (int i = 0; i < n; ++i) {
    tree[MAX_N - 1 + i] = r[i] - l[i] + 1;
    vals[MAX_N - 1 + i][0] = r[i];
  }
  for (int i = MAX_N - 2; i >= 0; --i) {
    tree[i] = tree[2 * i + 1] + tree[2 * i + 2];
    vals[i].resize(vals[2 * i + 1].size() + vals[2 * i + 2].size());
    int p1 = 0;
    int p2 = 0;
    int nxt = 0;
    while (p1 < vals[2 * i + 1].size() || p2 < vals[2 * i + 2].size()) {
      if (p1 == vals[2 * i + 1].size()) {
        vals[i][nxt++] = vals[2 * i + 2][p2++];
      } else if (p2 == vals[2 * i + 2].size()) {
        vals[i][nxt++] = vals[2 * i + 1][p1++];
      } else {
        if (vals[2 * i + 1][p1] < vals[2 * i + 2][p2]) {
          vals[i][nxt++] = vals[2 * i + 1][p1++];
        } else {
          vals[i][nxt++] = vals[2 * i + 2][p2++];
        }
      }
    }
  }
  sort(inters.begin(), inters.end(),
       [](pair<pair<int, int>, int> i, pair<pair<int, int>, int> j) {
         return i.first.second > j.first.second;
       });
  for (int i = 0; i < q; ++i) {
    res[inters[i].second] -=
        get(0, 0, MAX_N - 1, inters[i].first.first, inters[i].first.second, 1);
  }
  for (int i = 0; i < q; ++i) cout << res[i] << " ";
  cout << endl;
  return 0;
}
