#include <bits/stdc++.h>
using namespace std;
template <typename T>
struct fenwick_tree {
  int tree_n = 0;
  T tree_sum = 0;
  vector<T> tree;
  fenwick_tree(int n = 0) {
    if (n > 0) init(n);
  }
  void init(int n) {
    tree_n = n;
    tree_sum = 0;
    tree.assign(tree_n + 1, 0);
  }
  void update(int index, const T &change) {
    assert(0 <= index && index < tree_n);
    tree_sum += change;
    for (int i = index + 1; i <= tree_n; i += i & -i) tree[i] += change;
  }
  T query(int count) const {
    assert(count <= tree_n);
    T sum = 0;
    for (int i = count; i > 0; i -= i & -i) sum += tree[i];
    return sum;
  }
  T query_suffix(int start) const { return tree_sum - query(start); }
  T query(int a, int b) const { return query(b) - query(a); }
};
struct query {
  int L, R, index;
  query(int _L = -1, int _R = -1, int _index = -1)
      : L(_L), R(_R), index(_index) {}
};
int N, Q;
vector<int> P;
vector<query> queries;
vector<vector<query>> queries_at_point;
vector<long long> answers;
void solve_right_half() {
  vector<int> stack(N);
  vector<long long> stack_sum(N + 1, 0);
  int S = 0;
  fenwick_tree<long long> done_tree(N);
  for (int i = 0; i < N; i++) {
    while (S > 0 && P[i] > P[stack[S - 1]]) {
      done_tree.update(stack[S - 1], i - stack[S - 1] - 1);
      S--;
    }
    stack[S] = i;
    stack_sum[S + 1] = stack_sum[S] + i;
    S++;
    for (query &q : queries_at_point[i]) {
      answers[q.index] += done_tree.query_suffix(q.L);
      int index =
          lower_bound(stack.begin(), stack.begin() + S, q.L) - stack.begin();
      answers[q.index] +=
          (long long)i * (S - index) - (stack_sum[S] - stack_sum[index]);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> N >> Q;
  P.resize(N);
  queries.resize(Q);
  for (int i = 0; i < N; i++) cin >> P[i];
  for (int q = 0; q < Q; q++) queries[q].index = q;
  for (int q = 0; q < Q; q++) {
    cin >> queries[q].L;
    queries[q].L--;
  }
  for (int q = 0; q < Q; q++) {
    cin >> queries[q].R;
    queries[q].R--;
  }
  answers.assign(Q, 0);
  for (query &q : queries) answers[q.index] = q.R - q.L + 1;
  queries_at_point.assign(N, {});
  for (query &q : queries) queries_at_point[q.R].push_back(q);
  solve_right_half();
  for (query &q : queries) {
    q.L = N - 1 - q.L;
    q.R = N - 1 - q.R;
    swap(q.L, q.R);
  }
  reverse(P.begin(), P.end());
  queries_at_point.assign(N, {});
  for (query &q : queries) queries_at_point[q.R].push_back(q);
  solve_right_half();
  for (int q = 0; q < Q; q++) cout << answers[q] << (q < Q - 1 ? ' ' : '\n');
}
