#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 7;
struct Matrix {
  int a[2][2];
  Matrix() { memset(a, 0, sizeof(a)); }
  void init() {
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++) a[i][j] = (i == j);
  }
  Matrix operator+(const Matrix &B) const {
    Matrix C;
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++) C.a[i][j] = (a[i][j] + B.a[i][j]) % MOD;
    return C;
  }
  Matrix operator*(const Matrix &B) const {
    Matrix C;
    for (int i = 0; i < 2; i++)
      for (int k = 0; k < 2; k++)
        for (int j = 0; j < 2; j++)
          C.a[i][j] = (C.a[i][j] + 1LL * a[i][k] * B.a[k][j]) % MOD;
    return C;
  }
  Matrix operator^(const int &n) const {
    Matrix A = *this, res;
    res.init();
    int p = n;
    while (p) {
      if (p & 1) res = res * A;
      A = A * A;
      p >>= 1;
    }
    return res;
  }
};
int n, m;
int a[MAXN];
Matrix A, Tree[MAXN << 2], Lazy[MAXN << 2];
void pushup(int rt) { Tree[rt] = Tree[rt << 1] + Tree[rt << 1 | 1]; }
void pushdown(int rt) {
  Tree[rt << 1] = Lazy[rt] * Tree[rt << 1];
  Tree[rt << 1 | 1] = Lazy[rt] * Tree[rt << 1 | 1];
  Lazy[rt << 1] = Lazy[rt] * Lazy[rt << 1];
  Lazy[rt << 1 | 1] = Lazy[rt] * Lazy[rt << 1 | 1];
  Lazy[rt].init();
}
void build(int l, int r, int rt) {
  Lazy[rt].init();
  if (l == r) {
    Tree[rt] = A ^ a[l];
    return;
  }
  int m = (l + r) >> 1;
  build(l, m, rt << 1);
  build(m + 1, r, rt << 1 | 1);
  pushup(rt);
}
void update(int L, int R, Matrix x, int l, int r, int rt) {
  if (L <= l && r <= R) {
    Tree[rt] = Tree[rt] * x;
    Lazy[rt] = Lazy[rt] * x;
    return;
  }
  pushdown(rt);
  int m = (l + r) >> 1;
  if (L <= m) update(L, R, x, l, m, rt << 1);
  if (R > m) update(L, R, x, m + 1, r, rt << 1 | 1);
  pushup(rt);
}
int query(int L, int R, int l, int r, int rt) {
  if (L <= l && r <= R) return Tree[rt].a[1][0];
  pushdown(rt);
  int m = (l + r) >> 1;
  int res = 0;
  if (L <= m) res = (res + query(L, R, l, m, rt << 1)) % MOD;
  if (R > m) res = (res + query(L, R, m + 1, r, rt << 1 | 1)) % MOD;
  return res;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  A.a[0][0] = 1, A.a[0][1] = 1;
  A.a[1][0] = 1, A.a[1][1] = 0;
  cin >> n >> m;
  for (int i = 1; i < n + 1; i++) cin >> a[i];
  build(1, n, 1);
  while (m--) {
    int tp, l, r, x;
    cin >> tp >> l >> r;
    if (tp == 1) {
      cin >> x;
      update(l, r, A ^ x, 1, n, 1);
    } else
      cout << query(l, r, 1, n, 1) << endl;
  }
  return 0;
}
