#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 1e5 + 5;
struct Mat {
  long long x[2][2];
  void init() {
    x[0][0] = x[1][1] = 1;
    x[1][0] = x[0][1] = 0;
  }
  Mat operator*(const Mat& m2) const {
    Mat m;
    m.x[0][0] = m.x[0][1] = m.x[1][0] = m.x[1][1] = 0;
    for (int k = 0; k < 2; k++)
      for (int i = 0; i < 2; i++)
        for (int j = 0; j < 2; j++)
          m.x[i][j] = (m.x[i][j] + x[i][k] * m2.x[k][j]) % mod;
    return m;
  }
  Mat operator+(const Mat& m2) const {
    Mat m;
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++) m.x[i][j] = (x[i][j] + m2.x[i][j]) % mod;
    return m;
  }
};
Mat sum[maxn << 2], add[maxn << 2];
Mat pow(long long n) {
  Mat m, ret;
  m.x[0][0] = 1;
  m.x[0][1] = 1;
  m.x[1][0] = 1;
  m.x[1][1] = 0;
  ret.init();
  while (n) {
    if (n & 1) ret = ret * m;
    m = m * m;
    n >>= 1;
  }
  return ret;
}
long long solve(long long n) {
  Mat ret = pow(n);
  return ret.x[0][0];
}
void pushup(int rt) { sum[rt] = sum[rt << 1] + sum[rt << 1 | 1]; }
void build(int l, int r, int rt) {
  sum[rt].init();
  add[rt].init();
  if (l == r) {
    long long x;
    scanf("%lld", &x);
    sum[rt] = pow(x - 1);
    return;
  }
  int m = (l + r) >> 1;
  build(l, m, rt << 1);
  build(m + 1, r, rt << 1 | 1);
  pushup(rt);
}
void pushdown(int rt) {
  sum[rt << 1] = sum[rt << 1] * add[rt];
  sum[rt << 1 | 1] = sum[rt << 1 | 1] * add[rt];
  add[rt << 1] = add[rt << 1] * add[rt];
  add[rt << 1 | 1] = add[rt << 1 | 1] * add[rt];
  add[rt].init();
}
void update(int L, int R, Mat c, int l, int r, int rt) {
  if (L <= l && R >= r) {
    sum[rt] = sum[rt] * c;
    add[rt] = add[rt] * c;
    return;
  }
  pushdown(rt);
  int m = (l + r) >> 1;
  if (L <= m) update(L, R, c, l, m, rt << 1);
  if (R > m) update(L, R, c, m + 1, r, rt << 1 | 1);
  pushup(rt);
}
long long query(int L, int R, int l, int r, int rt) {
  if (L <= l && R >= r) return sum[rt].x[0][0];
  pushdown(rt);
  int m = (l + r) >> 1;
  long long ret = 0;
  if (L <= m) ret = (ret + query(L, R, l, m, rt << 1)) % mod;
  if (R > m) ret = (ret + query(L, R, m + 1, r, rt << 1 | 1)) % mod;
  pushup(rt);
  return ret;
}
void print(int l, int r, int rt) {
  if (l == r) {
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 2; j++) printf("%lld ", sum[rt].x[i][j]);
      printf("\n");
    }
    printf("\n");
    return;
  }
  int m = (l + r) >> 1;
  print(l, m, rt << 1);
  print(m + 1, r, rt << 1 | 1);
}
int n, m;
int main() {
  scanf("%d%d", &n, &m);
  build(1, n, 1);
  int op, a, b;
  long long x;
  while (m--) {
    scanf("%d%d%d", &op, &a, &b);
    if (op == 1) {
      scanf("%lld", &x);
      Mat m = pow(x);
      update(a, b, m, 1, n, 1);
    } else {
      printf("%lld\n", query(a, b, 1, n, 1));
    }
  }
  return 0;
}
