#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
int a[maxn];
int n, q, l, r, x, op;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    x = (x << 1) + (x << 3) + ch - '0';
  return x * f;
}
struct matrix {
  int mat[2][2];
  void setDiag() {
    mat[1][0] = mat[0][1] = 0;
    for (int i = 0; i < 2; i++) mat[i][i] = 1;
  }
  bool isDiag() {
    if (mat[0][0] != 1) return false;
    if (mat[0][1] != 0) return false;
    if (mat[1][0] != 0) return false;
    if (mat[1][1] != 1) return false;
    return true;
  }
  matrix operator*(const matrix &b) const {
    matrix c;
    memset(c.mat, 0, sizeof(c.mat));
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++)
        for (int k = 0; k < 2; k++)
          c.mat[i][j] = (c.mat[i][j] + 1LL * mat[k][j] * b.mat[i][k]) % mod;
    return c;
  }
  matrix operator+(const matrix &b) const {
    matrix c;
    memset(c.mat, 0, sizeof(c.mat));
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++) c.mat[i][j] = (mat[i][j] + b.mat[i][j]) % mod;
    return c;
  }
};
matrix fib;
matrix t, v;
matrix quick_pow(matrix a, int b) {
  t.setDiag();
  while (b) {
    if (b & 1) t = t * a;
    a = a * a;
    b >>= 1;
  }
  return t;
}
struct node {
  matrix c;
  matrix lazy;
} b[4 * maxn];
void pushup(int p) { b[p].c = b[p << 1].c + b[p << 1 | 1].c; }
void build(int p, int l, int r) {
  b[p].lazy.setDiag();
  if (l == r) {
    if (a[l] == 1) {
      b[p].c.mat[0][0] = 1;
      b[p].c.mat[1][0] = 1;
    } else {
      v = quick_pow(fib, a[l] - 1);
      b[p].c.mat[0][0] = (v.mat[0][0] + v.mat[0][1]) % mod;
      b[p].c.mat[1][0] = (v.mat[1][0] + v.mat[1][1]) % mod;
    }
    return;
  }
  int mid = (l + r) >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
  pushup(p);
}
void pushdown(int p) {
  if (!b[p].lazy.isDiag()) {
    b[p << 1].c = b[p << 1].c * b[p].lazy;
    b[p << 1 | 1].c = b[p << 1 | 1].c * b[p].lazy;
    b[p << 1].lazy = b[p << 1].lazy * b[p].lazy;
    b[p << 1 | 1].lazy = b[p << 1 | 1].lazy * b[p].lazy;
    b[p].lazy.setDiag();
  }
}
void modifySeg(int p, int l, int r, int L, int R) {
  if (L <= l && r <= R) {
    b[p].c = b[p].c * v;
    b[p].lazy = b[p].lazy * v;
    return;
  }
  int mid = (l + r) >> 1;
  pushdown(p);
  if (L <= mid) modifySeg(p << 1, l, mid, L, R);
  if (R > mid) modifySeg(p << 1 | 1, mid + 1, r, L, R);
  pushup(p);
}
matrix query(int p, int l, int r, int L, int R) {
  if (L <= l && r <= R) return b[p].c;
  int mid = (l + r) >> 1;
  pushdown(p);
  matrix sum;
  memset(sum.mat, 0, sizeof(sum.mat));
  if (L <= mid) sum = sum + query(p << 1, l, mid, L, R);
  if (R > mid) sum = sum + query(p << 1 | 1, mid + 1, r, L, R);
  return sum;
}
void dfsTree(int p, int l, int r) {
  printf("dfs %d %d %d %d %d\n", p, l, r, b[p].c.mat[0][0], b[p].c.mat[1][0]);
  if (l == r) return;
  int mid = (l + r) >> 1;
  pushdown(p);
  dfsTree(p << 1, l, mid);
  dfsTree(p << 1 | 1, mid + 1, r);
}
int main() {
  fib.mat[0][0] = 1;
  fib.mat[0][1] = 1;
  fib.mat[1][0] = 1;
  fib.mat[1][1] = 0;
  n = read();
  q = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  build(1, 1, n);
  while (q--) {
    op = read();
    if (op == 1) {
      l = read();
      r = read();
      x = read();
      v = quick_pow(fib, x);
      modifySeg(1, 1, n, l, r);
    } else {
      l = read();
      r = read();
      t = query(1, 1, n, l, r);
      printf("%d\n", t.mat[1][0]);
    }
  }
  return 0;
}
