#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
struct Matr0 {
  long long a[2][2];
} D[270000], DW, KW, VP, DEL;
struct Matr1 {
  long long a[2];
} B[270000], V0;
bool operator!=(Matr0 A, Matr0 B) {
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++)
      if (A.a[i][j] != B.a[i][j]) return 1;
  return 0;
}
Matr0 operator*(Matr0 A, Matr0 B) {
  Matr0 C = KW;
  for (int k = 0; k < 2; k++)
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++)
        C.a[i][j] = (C.a[i][j] + A.a[i][k] * B.a[k][j] % mod) % mod;
  return C;
}
Matr0 operator+(Matr0 A, Matr0 B) {
  Matr0 C;
  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;
}
Matr1 operator*(Matr1 A, Matr0 B) {
  Matr1 C;
  C.a[0] = (A.a[0] * B.a[0][0] % mod + A.a[1] * B.a[1][0] % mod) % mod;
  C.a[1] = (A.a[0] * B.a[0][1] % mod + A.a[1] * B.a[1][1] % mod) % mod;
  return C;
}
Matr1 operator+(Matr1 A, Matr1 B) {
  Matr1 C;
  C.a[0] = (A.a[0] + B.a[0]) % mod, C.a[1] = (A.a[1] + B.a[1]) % mod;
  return C;
}
Matr0 ksm(Matr0 A, long long k) {
  if (!k) return (DW);
  int p = 0, cp[70];
  Matr0 B = A;
  while (k > 1) {
    cp[++p] = k % 2;
    k /= 2;
  }
  for (; p >= 1; p--) {
    B = B * B;
    if (cp[p]) B = B * A;
  }
  return B;
}
int a0[100005];
long long ans;
void update(int x) { B[x] = B[(x << 1)] + B[((x << 1) | 1)]; }
void paint(int x, Matr0 M) {
  B[x] = B[x] * M;
  D[x] = D[x] * M;
}
void pushdown(int x) {
  if (D[x] != DW) {
    paint((x << 1), D[x]);
    paint(((x << 1) | 1), D[x]);
    D[x] = DW;
  }
}
void build(int x, int l, int r) {
  int mid = ((l + r) >> 1);
  D[x] = DW;
  if (l == r) {
    B[x] = V0 * ksm(VP, a0[l] - 1);
    return;
  }
  build((x << 1), l, mid);
  build(((x << 1) | 1), mid + 1, r);
  update(x);
}
void modify(int x, int l, int r, int ql, int qr) {
  int mid = ((l + r) >> 1);
  if (ql <= l && r <= qr) {
    paint(x, DEL);
    return;
  }
  pushdown(x);
  if (ql <= mid) modify((x << 1), l, mid, ql, qr);
  if (mid < qr) modify(((x << 1) | 1), mid + 1, r, ql, qr);
  update(x);
}
void query(int x, int l, int r, int ql, int qr) {
  int mid = ((l + r) >> 1);
  if (ql <= l && r <= qr) {
    ans = (ans + B[x].a[1]) % mod;
    return;
  }
  pushdown(x);
  if (ql <= mid) query((x << 1), l, mid, ql, qr);
  if (mid < qr) query(((x << 1) | 1), mid + 1, r, ql, qr);
  update(x);
}
void init() {
  int i, j;
  for (i = 0; i < 2; i++)
    for (j = 0; j < 2; j++) {
      if (i == j)
        DW.a[i][j] = 1;
      else
        DW.a[i][j] = 0;
      if (i == j && i == 0)
        VP.a[i][j] = 0;
      else
        VP.a[i][j] = 1;
      KW.a[i][j] = 0;
    }
  V0.a[0] = 0, V0.a[1] = 1;
}
int main() {
  int i, n, q;
  scanf("%d%d", &n, &q);
  init();
  for (i = 1; i <= n; i++) scanf("%d", &a0[i]);
  build(1, 1, n);
  while (q--) {
    int op, l, r, x;
    scanf("%d%d%d", &op, &l, &r);
    if (op == 1) {
      scanf("%d", &x);
      DEL = ksm(VP, x);
      modify(1, 1, n, l, r);
    } else {
      ans = 0;
      query(1, 1, n, l, r);
      printf("%I64d\n", ans);
    }
  }
  return 0;
}
