#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 100000 + 10;
int n, m;
struct mat {
  int num[3][3];
  mat operator*(const mat &sjb) const {
    mat res;
    res.num[1][1] = res.num[1][2] = res.num[2][1] = res.num[2][2] = 0;
    for (int i = 1; i <= 2; ++i)
      for (int j = 1; j <= 2; ++j)
        for (int k = 1; k <= 2; ++k)
          res.num[i][j] =
              ((long long)res.num[i][j] % mod +
               ((long long)num[i][k] % mod * (long long)sjb.num[k][j] % mod)) %
              mod;
    return res;
  }
  mat operator+(const mat &sjb) const {
    mat res;
    res.num[1][1] = res.num[1][2] = res.num[2][1] = res.num[2][2] = 0;
    for (int i = 1; i <= 2; ++i)
      for (int j = 1; j <= 2; ++j)
        res.num[i][j] =
            ((long long)num[i][j] % mod + (long long)sjb.num[i][j] % mod) % mod;
    return res;
  }
  bool emp() {
    bool flag = 1;
    for (int i = 1; i <= 2; ++i)
      for (int j = 1; j <= 2; ++j)
        if (num[i][j] != 0) flag = 0;
    return flag;
  }
} zy, k0, st;
mat quickpow(mat a, int k) {
  if (k == 0) return k0;
  mat tmp = quickpow(a, k >> 1);
  tmp = tmp * tmp;
  if (k & 1) tmp = tmp * a;
  return tmp;
}
struct node {
  mat sum;
  mat tag;
} tree[maxn << 2];
inline void pushup(int rt) {
  tree[rt].sum = tree[rt << 1].sum + tree[rt << 1 | 1].sum;
}
inline void pushdown(int rt) {
  tree[rt << 1].tag = tree[rt << 1].tag * tree[rt].tag;
  tree[rt << 1 | 1].tag = tree[rt << 1 | 1].tag * tree[rt].tag;
  tree[rt << 1].sum = tree[rt << 1].sum * tree[rt].tag;
  tree[rt << 1 | 1].sum = tree[rt << 1 | 1].sum * tree[rt].tag;
  tree[rt].tag.num[1][1] = tree[rt].tag.num[1][2] = tree[rt].tag.num[2][1] =
      tree[rt].tag.num[2][2] = 0;
  tree[rt].tag.num[1][1] = tree[rt].tag.num[2][2] = 1;
}
void build(int rt, int l, int r) {
  tree[rt].tag.num[1][1] = tree[rt].tag.num[2][2] = 1;
  if (l == r) {
    int x;
    scanf("%d", &x);
    tree[rt].sum = st * quickpow(zy, x - 1);
    return;
  }
  build(rt << 1, l, ((l + r) >> 1)), build(rt << 1 | 1, ((l + r) >> 1) + 1, r);
  pushup(rt);
}
void update(int rt, int l, int r, int L, int R, mat k) {
  if (L <= l && r <= R) {
    tree[rt].sum = tree[rt].sum * k;
    tree[rt].tag = tree[rt].tag * k;
    return;
  }
  if (!(tree[rt].tag.emp())) pushdown(rt);
  if (R <= ((l + r) >> 1))
    update(rt << 1, l, ((l + r) >> 1), L, R, k);
  else if (L > ((l + r) >> 1))
    update(rt << 1 | 1, ((l + r) >> 1) + 1, r, L, R, k);
  else
    update(rt << 1, l, ((l + r) >> 1), L, ((l + r) >> 1), k),
        update(rt << 1 | 1, ((l + r) >> 1) + 1, r, ((l + r) >> 1) + 1, R, k);
  pushup(rt);
}
int query(int rt, int l, int r, int L, int R) {
  if (L <= l && r <= R) return tree[rt].sum.num[1][1];
  if (!(tree[rt].tag.emp())) pushdown(rt);
  if (R <= ((l + r) >> 1)) return query(rt << 1, l, ((l + r) >> 1), L, R);
  if (L > ((l + r) >> 1))
    return query(rt << 1 | 1, ((l + r) >> 1) + 1, r, L, R);
  return ((long long)query(rt << 1, l, ((l + r) >> 1), L, ((l + r) >> 1)) +
          (long long)query(rt << 1 | 1, ((l + r) >> 1) + 1, r,
                           ((l + r) >> 1) + 1, R)) %
         mod;
}
inline int read() {
  int res = 0;
  char c = getchar();
  while (c < 48 || c > 57) c = getchar();
  while (c >= 48 && c <= 57)
    res = (res << 3) + (res << 1) + (c & 15), c = getchar();
  return res;
}
int main() {
  zy.num[1][2] = zy.num[2][1] = zy.num[2][2] = 1;
  k0.num[1][1] = k0.num[2][2] = 1;
  st.num[1][1] = st.num[1][2] = 1;
  scanf("%d%d", &n, &m);
  build(1, 1, n);
  int l, r, opt, x;
  for (int _ = 1; _ <= m; ++_) {
    opt = read();
    l = read();
    r = read();
    if (opt == 1) {
      x = read();
      mat sjbbb = quickpow(zy, x);
      update(1, 1, n, l, r, sjbbb);
    } else
      printf("%d\n", query(1, 1, n, l, r));
  }
}
