#include <bits/stdc++.h>
using namespace std;
const int p = 1e9 + 7;
int n, q, a[200100], sumaw[530000], ql, qr;
long long sumw[530000], sum1, sum2;
int getint() {
  char ch;
  while (!isdigit(ch = getchar()) && ch != '-')
    ;
  bool flag = ch == '-';
  if (flag) ch = getchar();
  int x = ch - '0';
  for (; isdigit(ch = getchar()); x = x * 10 + ch - '0')
    ;
  return flag ? -x : x;
}
void update(int x) {
  sumw[x] = sumw[x << 1] + sumw[x << 1 | 1];
  sumaw[x] = (sumaw[x << 1] + sumaw[x << 1 | 1]) % p;
}
void build(int x, int l, int r) {
  if (l == r) {
    sumw[x] = getint(), sumaw[x] = long long(a[l]) * sumw[x] % p;
    return;
  }
  build(x << 1, l, ((l + r) >> 1)), build(x << 1 | 1, ((l + r) >> 1) + 1, r),
      update(x);
}
void modify(int x, int l, int r, int k, int w) {
  if (l == r) {
    sumw[x] = w, sumaw[x] = long long(a[l]) * w % p;
    return;
  }
  if (k <= ((l + r) >> 1))
    modify(x << 1, l, ((l + r) >> 1), k, w);
  else
    modify(x << 1 | 1, ((l + r) >> 1) + 1, r, k, w);
  update(x);
}
void get(int x, int l, int r) {
  if (ql <= l && qr >= r) {
    sum1 += sumw[x], sum2 += sumaw[x];
    return;
  }
  if (ql <= ((l + r) >> 1)) get(x << 1, l, ((l + r) >> 1));
  if (qr > ((l + r) >> 1)) get(x << 1 | 1, ((l + r) >> 1) + 1, r);
}
bool query(int x, int l, int r, long long &s1, long long &s2) {
  if (ql <= l && qr >= r && (s1 + sumw[x]) * 2 <= sum1) {
    s1 += sumw[x], (s2 += sumaw[x]) %= p;
    return 0;
  }
  if (l == r) {
    printf("%d\n",
           ((s1 - (sum1 - s1)) % p * (a[l]) + p - s2 + (sum2 + p - s2)) % p);
    return 1;
  }
  if (ql <= ((l + r) >> 1) && query(x << 1, l, ((l + r) >> 1), s1, s2))
    return 1;
  return query(x << 1 | 1, ((l + r) >> 1) + 1, r, s1, s2);
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; ++i) a[i] = getint() + n - i;
  build(1, 1, n);
  while (q--) {
    ql = getint(), qr = getint();
    if (ql < 0)
      modify(1, 1, n, -ql, qr);
    else {
      sum1 = 0, sum2 = 0, get(1, 1, n);
      long long s1 = 0, s2 = 0;
      query(1, 1, n, s1, s2);
    }
  }
  return 0;
}
