#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7, MxN = 1e6 + 7, mod = 1e9 + 7, inf = 2e9 + 7;
const long long linf = (long long)1e18 + 7;
const double eps = 1e-9;
const int ii[] = {-1, 0, 1, 0, 1, -1, -1, 1},
          jj[] = {0, 1, 0, -1, 1, -1, 1, -1};
int n, m;
int a[N];
struct Matrix {
  int a[2][2];
  inline Matrix() { memset(a, 0, sizeof(a)); }
  inline Matrix(int _1, int _2, int _3, int _4) {
    a[0][0] = _1, a[0][1] = _2, a[1][0] = _3, a[1][1] = _4;
  }
  inline void New() {
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++) a[i][j] = 1;
    a[0][0] = 0;
  }
} t[MxN], mt, add[MxN];
inline Matrix operator*(const Matrix &a, const Matrix &b) {
  Matrix res;
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++)
      for (int k = 0; k < 2; k++)
        res.a[i][j] = (res.a[i][j] + a.a[i][k] * (long long)b.a[k][j]) % mod;
  return res;
}
inline Matrix operator+(const Matrix &a, const Matrix &b) {
  Matrix res;
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) res.a[i][j] = (a.a[i][j] + b.a[i][j]) % mod;
  return res;
}
inline Matrix Bp(Matrix a, long long b) {
  Matrix res;
  res.a[0][0] = res.a[1][1] = 1;
  while (b) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
inline void Push(int v, int tl, int tr) {
  if (tl != tr) {
    add[v + v] = add[v + v] * add[v];
    add[v + v + 1] = add[v + v + 1] * add[v];
    t[v + v] = t[v + v] * add[v];
    t[v + v + 1] = t[v + v + 1] * add[v];
    add[v] = Matrix(1, 0, 0, 1);
  }
}
inline void Build(int v = 1, int tl = 1, int tr = n) {
  add[v] = Matrix(1, 0, 0, 1);
  if (tl == tr) {
    t[v] = Bp(mt, a[tl]);
    return;
  }
  int tm = tl + tr >> 1;
  Build(v + v, tl, tm);
  Build(v + v + 1, tm + 1, tr);
  t[v] = t[v + v] + t[v + v + 1];
}
inline void Update(int l, int r, Matrix val, int v = 1, int tl = 1,
                   int tr = n) {
  Push(v, tl, tr);
  if (l <= tl && tr <= r) {
    t[v] = t[v] * val;
    add[v] = add[v] * val;
    return;
  }
  if (tl > r || tr < l) return;
  int tm = tl + tr >> 1;
  Update(l, r, val, v + v, tl, tm);
  Update(l, r, val, v + v + 1, tm + 1, tr);
  t[v] = t[v + v] + t[v + v + 1];
}
inline Matrix Get(int l, int r, int v = 1, int tl = 1, int tr = n) {
  Push(v, tl, tr);
  if (l <= tl && tr <= r) return t[v];
  if (tl > r || tr < l) return {0, 0, 0, 0};
  int tm = tl + tr >> 1;
  return Get(l, r, v + v, tl, tm) + Get(l, r, v + v + 1, tm + 1, tr);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  mt.New();
  Build();
  for (int i = 1, type, l, r, x; i <= m; i++) {
    scanf("%d%d%d", &type, &l, &r);
    if (type == 1) {
      scanf("%d", &x);
      Update(l, r, Bp(mt, x));
    } else
      printf("%d\n", Get(l, r).a[0][1]);
  }
  exit(0);
}
