#include <bits/stdc++.h>
using namespace std;
int i, j, n, k, l, m, x, y, tot, flag, h, r, ans, koko;
int a[1000500];
long long to_push[1005000];
string s;
struct fib {
  int x, y;
  fib() {
    x = 0;
    y = 1;
  }
  fib(int x, int y) {
    this->x = x;
    this->y = y;
  }
};
fib t[400500];
fib add(fib x, fib y) {
  return fib((x.x + y.x) % 1000000007, (x.y + y.y) % 1000000007);
}
fib multiply(fib x, fib y) {
  return fib(
      (1LL * x.x * (y.y - y.x + 1000000007) + 1LL * x.y * y.x) % 1000000007,
      (1LL * x.x * y.x + 1LL * x.y * y.y) % 1000000007);
}
fib binpow(long long x) {
  if (x == 0) {
    return fib();
  }
  fib tmp = binpow(x / 2);
  tmp = multiply(tmp, tmp);
  if (x % 2 == 1) {
    tmp = multiply(fib(1, 1), tmp);
    return tmp;
  }
  return tmp;
}
fib updateF(fib x, long long y) {
  if (y == 0) return x;
  fib t = binpow(y);
  return fib(
      (1LL * x.x * (t.y - t.x + 1000000007) + 1LL * x.y * t.x) % 1000000007,
      (1LL * x.x * t.x + 1LL * x.y * t.y) % 1000000007);
}
void build(int a[], int v, int tl, int tr) {
  if (tl == tr)
    t[v] = binpow(a[tl]);
  else {
    int tm = (tl + tr) / 2;
    build(a, v * 2, tl, tm);
    build(a, v * 2 + 1, tm + 1, tr);
    t[v] = add(t[v * 2], t[v * 2 + 1]);
  }
}
fib sum(int v, int tl, int tr, int l, int r) {
  if (l > r) {
    return fib(0, 0);
  }
  if (l == tl && r == tr) return updateF(t[v], to_push[v]);
  int tm = (tl + tr) / 2;
  t[v] = updateF(t[v], to_push[v]);
  to_push[v * 2] += to_push[v];
  to_push[v * 2 + 1] += to_push[v];
  to_push[v] = 0;
  return add(sum(v * 2, tl, tm, l, min(r, tm)),
             sum(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
}
void update(int v, int tl, int tr, int l, int r, int ad) {
  if (l > r) return;
  if (l == tl && tr == r)
    to_push[v] += ad;
  else {
    int tm = (tl + tr) / 2;
    to_push[v * 2] += to_push[v];
    to_push[v * 2 + 1] += to_push[v];
    to_push[v] = 0;
    update(v * 2, tl, tm, l, min(r, tm), ad);
    update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, ad);
    fib t1 = updateF(t[v * 2], to_push[v * 2]);
    fib t2 = updateF(t[v * 2 + 1], to_push[v * 2 + 1]);
    t[v] = add(t1, t2);
  }
}
int main() {
  cin >> n >> m;
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  build(a, 1, 0, n - 1);
  for (i = 0; i < m; i++) {
    int test;
    scanf("%d", &test);
    if (test == 1) {
      scanf("%d %d %d", &l, &r, &x);
      l--;
      r--;
      update(1, 0, n - 1, l, r, x);
    } else {
      scanf("%d %d", &l, &r);
      l--;
      r--;
      printf("%d\n", sum(1, 0, n - 1, l, r).x);
    }
  }
  return 0;
}
