#include <bits/stdc++.h>
using namespace std;
struct Matrix {
  int n, m;
  long long a[3][3];
  Matrix(int _n, int _m) {
    memset(a, 0, sizeof(a));
    n = _n;
    m = _m;
  }
  void newUnitMatrix(int _n) {
    n = m = _n;
    memset(a, 0, sizeof(a));
    for (int i = 1; i <= n; i++) a[i][i] = 1;
  }
  inline long long* operator[](int x) { return a[x]; }
  inline Matrix operator*(Matrix b) {
    Matrix c(n, b.m);
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= b.m; j++) {
        for (int k = 1; k <= m; k++) {
          c[i][j] =
              (c[i][j] + (a[i][k] * b[k][j] % 1000000007ll)) % 1000000007ll;
        }
      }
    }
    return c;
  }
};
int a[100010], n, m;
inline Matrix ksm(Matrix a, long long b) {
  Matrix ret(a.n, a.n);
  ret.newUnitMatrix(a.n);
  while (b) {
    if (b & 1) ret = ret * a;
    a = a * a;
    b >>= 1;
  }
  return ret;
}
inline long long getfib(long long x) {
  if (x == 0) return 0;
  if (x == 1 || x == 2) return 1;
  Matrix a(1, 2);
  a[1][1] = 1;
  a[1][2] = 1;
  Matrix trans(2, 2);
  trans[1][1] = 1;
  trans[1][2] = 1;
  trans[2][1] = 1;
  trans[2][2] = 0;
  a = a * ksm(trans, x - 2);
  return a[1][1];
}
struct node {
  int l, r;
  long long x1, x2, tag1, tag2;
} t[100010 << 2];
void pushup(int rt) {
  t[rt].x1 = (t[rt << 1].x1 + t[rt << 1 | 1].x1) % 1000000007ll;
  t[rt].x2 = (t[rt << 1].x2 + t[rt << 1 | 1].x2) % 1000000007ll;
}
void pushdown(int rt) {
  long long x1, x2, t1, t2;
  if (t[rt].tag1 != 0 || t[rt].tag2 != 0) {
    t1 = (t[rt].tag1 * t[rt << 1].tag1 % 1000000007ll +
          t[rt].tag2 * t[rt << 1].tag2 % 1000000007ll) %
         1000000007ll;
    t2 = ((t[rt].tag1 * t[rt << 1].tag2 % 1000000007ll +
           t[rt].tag2 * t[rt << 1].tag1 % 1000000007ll -
           t[rt].tag2 * t[rt << 1].tag2 % 1000000007ll) %
              1000000007ll +
          1000000007ll) %
         1000000007ll;
    t[rt << 1].tag1 = t1;
    t[rt << 1].tag2 = t2;
    x1 = (t[rt << 1].x1 * t[rt].tag1 % 1000000007ll +
          t[rt << 1].x2 * t[rt].tag2 % 1000000007ll) %
         1000000007ll;
    x2 = (t[rt << 1].x1 * t[rt].tag2 % 1000000007ll +
          t[rt << 1].x2 *
              ((t[rt].tag1 - t[rt].tag2) % 1000000007ll + 1000000007ll) %
              1000000007ll) %
         1000000007ll;
    t[rt << 1].x1 = x1;
    t[rt << 1].x2 = x2;
    t1 = (t[rt].tag1 * t[rt << 1 | 1].tag1 % 1000000007ll +
          t[rt].tag2 * t[rt << 1 | 1].tag2 % 1000000007ll) %
         1000000007ll;
    t2 = ((t[rt].tag1 * t[rt << 1 | 1].tag2 % 1000000007ll +
           t[rt].tag2 * t[rt << 1 | 1].tag1 % 1000000007ll -
           t[rt].tag2 * t[rt << 1 | 1].tag2 % 1000000007ll) %
              1000000007ll +
          1000000007ll) %
         1000000007ll;
    t[rt << 1 | 1].tag1 = t1;
    t[rt << 1 | 1].tag2 = t2;
    x1 = (t[rt << 1 | 1].x1 * t[rt].tag1 % 1000000007ll +
          t[rt << 1 | 1].x2 * t[rt].tag2 % 1000000007ll) %
         1000000007ll;
    x2 = (t[rt << 1 | 1].x1 * t[rt].tag2 % 1000000007ll +
          t[rt << 1 | 1].x2 *
              ((t[rt].tag1 - t[rt].tag2) % 1000000007ll + 1000000007ll) %
              1000000007ll) %
         1000000007ll;
    t[rt << 1 | 1].x1 = x1;
    t[rt << 1 | 1].x2 = x2;
    t[rt].tag1 = 1;
    t[rt].tag2 = 0;
  }
}
void build(int rt, int l, int r) {
  t[rt].l = l;
  t[rt].r = r;
  t[rt].tag1 = 1;
  t[rt].tag2 = 0;
  if (l == r) {
    t[rt].x1 = getfib(a[l]);
    t[rt].x2 = getfib(a[l] - 1);
    return;
  }
  int mid = (l + r) >> 1;
  build(rt << 1, l, mid);
  build(rt << 1 | 1, mid + 1, r);
  pushup(rt);
}
long long query(int rt, int l, int r) {
  if (l <= t[rt].l && t[rt].r <= r) {
    return t[rt].x1;
  }
  pushdown(rt);
  int mid = (t[rt].l + t[rt].r) >> 1;
  long long ret = 0;
  if (l <= mid) ret = (ret + query(rt << 1, l, r)) % 1000000007ll;
  if (mid < r) ret = (ret + query(rt << 1 | 1, l, r)) % 1000000007ll;
  return ret;
}
void modify(int rt, int l, int r, long long c1, long long c2) {
  if (l <= t[rt].l && t[rt].r <= r) {
    long long x1, x2, t1, t2;
    t1 = (c1 * t[rt].tag1 % 1000000007ll + c2 * t[rt].tag2 % 1000000007ll) %
         1000000007ll;
    t2 = ((c1 * t[rt].tag2 % 1000000007ll + c2 * t[rt].tag1 % 1000000007ll -
           c2 * t[rt].tag2 % 1000000007ll) %
              1000000007ll +
          1000000007ll) %
         1000000007ll;
    t[rt].tag1 = t1;
    t[rt].tag2 = t2;
    x1 = (t[rt].x1 * c1 % 1000000007ll + t[rt].x2 * c2 % 1000000007ll) %
         1000000007ll;
    x2 = (t[rt].x1 * c2 % 1000000007ll +
          t[rt].x2 * ((c1 - c2) % 1000000007ll + 1000000007ll) % 1000000007ll) %
         1000000007ll;
    t[rt].x1 = x1;
    t[rt].x2 = x2;
    return;
  }
  pushdown(rt);
  int mid = (t[rt].l + t[rt].r) >> 1;
  if (l <= mid) modify(rt << 1, l, r, c1, c2);
  if (mid < r) modify(rt << 1 | 1, l, r, c1, c2);
  pushup(rt);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  build(1, 1, n);
  while (m--) {
    int opt, x, y, z;
    scanf("%d%d%d", &opt, &x, &y);
    if (opt == 2) {
      printf("%I64d\n", query(1, x, y));
    } else {
      scanf("%d", &z);
      long long c1 = getfib(z + 1), c2 = getfib(z);
      modify(1, x, y, c1, c2);
    }
  }
  return 0;
}
