#include <bits/stdc++.h>
using namespace std;
const int MX = 1e5 + 10;
const long long mod = 1e9 + 7;
struct mat {
  long long a[3][3];
  mat() { memset(a, 0, sizeof(a)); }
  void mat1() {
    a[1][1] = a[2][2] = 1;
    a[1][2] = a[2][1] = 0;
  }
};
mat multi(mat m1, mat m2) {
  mat ans = mat();
  for (int i = 1; i <= 2; i++)
    for (int j = 1; j <= 2; j++)
      if (m1.a[i][j])
        for (int k = 1; k <= 2; k++)
          ans.a[i][k] = (ans.a[i][k] + m1.a[i][j] * m2.a[j][k] % mod) % mod;
  return ans;
}
mat quick_pow(mat m, long long n) {
  mat ans;
  ans.mat1();
  while (n) {
    if (n & 1) ans = multi(ans, m);
    m = multi(m, m);
    n >>= 1;
  }
  return ans;
}
mat add(mat m1, mat m2) {
  mat ans = mat();
  for (int i = 1; i <= 2; i++)
    for (int j = 1; j <= 2; j++)
      ans.a[i][j] = (ans.a[i][j] + m1.a[i][j] + m2.a[i][j]) % mod;
  return ans;
}
int n, m;
mat sum[MX << 2], col[MX << 2];
mat vis = mat(), cnt = mat();
void init() {
  vis.a[1][1] = 1;
  vis.a[1][2] = 1;
  vis.a[2][1] = 1;
  cnt.a[1][1] = 1;
  cnt.a[2][1] = 0;
}
void push_up(int rt) { sum[rt] = add(sum[rt << 1], sum[rt << 1 | 1]); }
void push_down(int rt) {
  col[rt << 1] = multi(col[rt << 1], col[rt]);
  col[rt << 1 | 1] = multi(col[rt << 1 | 1], col[rt]);
  sum[rt << 1] = multi(col[rt], sum[rt << 1]);
  sum[rt << 1 | 1] = multi(col[rt], sum[rt << 1 | 1]);
  col[rt].mat1();
}
void build(int l, int r, int rt) {
  col[rt].mat1();
  sum[rt].mat1();
  if (l == r) {
    long long x;
    scanf("%I64d", &x);
    sum[rt] = multi(quick_pow(vis, x - 1), cnt);
    return;
  }
  int m = (l + r) >> 1;
  build(l, m, rt << 1);
  build(m + 1, r, rt << 1 | 1);
  push_up(rt);
}
void update(int L, int R, mat d, int l, int r, int rt) {
  if (L <= l && r <= R) {
    col[rt] = multi(d, col[rt]);
    sum[rt] = multi(d, sum[rt]);
    return;
  }
  push_down(rt);
  int m = (l + r) >> 1;
  if (L <= m) update(L, R, d, l, m, rt << 1);
  if (R > m) update(L, R, d, m + 1, r, rt << 1 | 1);
  push_up(rt);
}
long long query(int L, int R, int l, int r, int rt) {
  if (L <= l && r <= R) {
    return sum[rt].a[1][1];
  }
  push_down(rt);
  long long res = 0;
  int m = (l + r) >> 1;
  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() {
  init();
  while (~scanf("%d %d", &n, &m)) {
    build(1, n, 1);
    for (int i = 0; i < m; i++) {
      int tp, l, r, d;
      scanf("%d", &tp);
      if (tp == 1) {
        scanf("%d %d %d", &l, &r, &d);
        mat kk = quick_pow(vis, d);
        update(l, r, kk, 1, n, 1);
      } else {
        scanf("%d %d", &l, &r);
        long long ans = query(l, r, 1, n, 1);
        printf("%I64d\n", ans);
      }
    }
  }
  return 0;
}
