#include <bits/stdc++.h>
using namespace std;
const int N = 100010, mod = 1000000007;
int n, m, ql, qr, a[N];
struct mt {
  long long a[2][2];
  mt() { memset(a, 0, sizeof(a)); }
  void clear() { memset(a, 0, sizeof(a)); }
} m0, qm, res, p, d[N];
struct st {
  mt a, lz;
} t[N * 4];
mt operator*(mt x, mt y) {
  mt z;
  for (int i = 0; i <= 1; i++) {
    for (int k = 0; k <= 1; k++) {
      for (int j = 0; j <= 1; j++) (z.a[i][j] += x.a[i][k] * y.a[k][j]) %= mod;
    }
  }
  return z;
}
mt operator+(mt x, mt y) {
  mt z;
  for (int i = 0; i <= 1; i++) {
    for (int j = 0; j <= 1; j++) z.a[i][j] = (x.a[i][j] + y.a[i][j]) % mod;
  }
  return z;
}
void pd(int x, int l, int r) {
  t[x].a = t[x].a * t[x].lz;
  if (l != r)
    t[x << 1].lz = t[x << 1].lz * t[x].lz,
           t[x << 1 | 1].lz = t[x << 1 | 1].lz * t[x].lz;
  t[x].lz = m0;
}
void add(int x, int l, int r) {
  pd(x, l, r);
  if (ql > r || qr < l) return;
  if (ql <= l && r <= qr) {
    t[x].lz = t[x].lz * qm;
    pd(x, l, r);
    return;
  }
  int mid = (l + r) >> 1;
  add(x << 1, l, mid), add(x << 1 | 1, mid + 1, r);
  t[x].a = t[x << 1].a + t[x << 1 | 1].a;
}
void qry(int x, int l, int r) {
  pd(x, l, r);
  if (ql > r || qr < l) return;
  if (ql <= l && r <= qr) {
    res = res + t[x].a;
    return;
  }
  int mid = (l + r) >> 1;
  qry(x << 1, l, mid), qry(x << 1 | 1, mid + 1, r);
}
void build(int x, int l, int r) {
  t[x].lz = m0;
  if (l == r) {
    t[x].a = d[l];
    return;
  }
  int mid = (l + r) >> 1;
  build(x << 1, l, mid), build(x << 1 | 1, mid + 1, r);
  t[x].a = t[x << 1].a + t[x << 1 | 1].a;
}
mt find(int x) {
  qm = m0;
  qm.a[0][1] = 1;
  x--;
  p.a[0][0] = 0;
  p.a[0][1] = p.a[1][1] = p.a[1][0] = 1;
  while (x) {
    if (x & 1) qm = qm * p;
    p = p * p;
    x >>= 1;
  }
  return qm;
}
int main() {
  scanf("%d%d", &n, &m);
  m0.a[0][0] = m0.a[1][1] = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    d[i] = find(a[i]);
  }
  build(1, 1, n);
  while (m--) {
    int x, t;
    scanf("%d%d%d", &t, &ql, &qr);
    res.clear();
    qm = p = m0;
    if (t == 1) {
      scanf("%d", &x);
      p.a[0][0] = 0;
      p.a[0][1] = p.a[1][1] = p.a[1][0] = 1;
      while (x) {
        if (x & 1) qm = qm * p;
        p = p * p;
        x >>= 1;
      }
      add(1, 1, n);
    } else {
      qry(1, 1, n);
      printf("%I64d\n", res.a[0][0]);
    }
  }
  return 0;
}
