#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
struct node {
  long long a[3][3];
} A, B, C;
struct nod {
  int l, r, ls, rs;
  node M, bj;
} a[1000005];
int n, m, aa[100005], cnt, rt;
node operator+(const node &a, const node &b) {
  node c;
  memset(c.a, 0, sizeof(c.a));
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) c.a[i][j] = (a.a[i][j] + b.a[i][j]) % MOD;
  return c;
}
node operator*(const node &a, const node &b) {
  node c;
  memset(c.a, 0, sizeof(c.a));
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++)
      for (int k = 0; k < 2; k++)
        c.a[i][j] = (c.a[i][j] + a.a[i][k] * b.a[k][j] % MOD) % MOD;
  return c;
}
node calc(int x) {
  node k = A, kk = B;
  while (x) {
    if (x & 1) kk = kk * k;
    k = k * k;
    x /= 2;
  }
  return kk;
}
void build(int &x, int l, int r) {
  if (!x) x = ++cnt;
  a[x].l = l;
  a[x].r = r;
  if (l == r) {
    a[x].M = calc(aa[l]);
    a[x].bj = B;
    return;
  }
  build(a[x].ls, l, (l + r) / 2);
  build(a[x].rs, (l + r) / 2 + 1, r);
  a[x].M = a[a[x].ls].M + a[a[x].rs].M;
  a[x].bj = B;
}
void add(int x, int l, int r, node k) {
  if (a[x].l >= l && a[x].r <= r) {
    a[x].bj = a[x].bj * k;
    a[x].M = a[x].M * k;
    return;
  }
  if (a[x].l == a[x].r) return;
  int mid = (a[x].l + a[x].r) / 2;
  if (l <= mid) add(a[x].ls, l, r, k);
  if (r > mid) add(a[x].rs, l, r, k);
  a[x].M = (a[a[x].ls].M + a[a[x].rs].M) * a[x].bj;
}
node find(int x, int l, int r) {
  if (a[x].l >= l && a[x].r <= r) return a[x].M;
  if (a[x].l == a[x].r) return C;
  node tp;
  memset(tp.a, 0, sizeof(tp.a));
  int mid = (a[x].l + a[x].r) / 2;
  if (l <= mid) tp = tp + find(a[x].ls, l, r);
  if (r > mid) tp = tp + find(a[x].rs, l, r);
  return tp * a[x].bj;
}
int main() {
  A.a[0][0] = 0;
  A.a[0][1] = A.a[1][0] = A.a[1][1] = 1;
  B.a[0][0] = B.a[1][1] = 1;
  B.a[0][1] = B.a[1][0] = 0;
  C.a[0][0] = C.a[1][1] = C.a[0][1] = C.a[1][0] = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &aa[i]);
  build(rt, 1, n);
  for (int i = 1, sg, l, r, kk; i <= m; i++) {
    scanf("%d%d%d", &sg, &l, &r);
    if (sg == 1) {
      scanf("%d", &kk);
      node k = calc(kk);
      add(rt, l, r, k);
    } else
      printf("%I64d\n", find(rt, l, r).a[0][1]);
  }
  return 0;
}
