#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, M = 2, MOD = 1e9 + 7;
struct mat {
  long long a[2][2];
  mat() { a[0][0] = a[1][1] = a[0][1] = a[1][0] = 0; }
  void fib() {
    a[0][0] = 0;
    a[0][1] = a[1][1] = a[1][0] = 1;
  }
} Fib, I;
mat mul(const mat &a, const mat &b) {
  mat ret = mat();
  for (int i = 0; i < M; i++)
    for (int j = 0; j < M; j++)
      for (int k = 0; k < M; k++) {
        ret.a[i][j] += (a.a[i][k] * b.a[k][j]) % MOD;
        ret.a[i][j] %= MOD;
      }
  return ret;
}
mat add(const mat &a, const mat &b) {
  mat ret = mat();
  for (int i = 0; i < M; i++)
    for (int j = 0; j < M; j++) ret.a[i][j] = (a.a[i][j] + b.a[i][j]) % MOD;
  return ret;
}
mat bp(const mat &a, int cnt) {
  mat ret = mat();
  if (cnt == 0) return I;
  ret = bp(a, cnt / 2);
  ret = mul(ret, ret);
  return cnt & 1 ? mul(ret, a) : ret;
}
mat seg[4 * N], lazy[4 * N];
int n, a[N];
void build(int s = 0, int e = n, int id = 1) {
  lazy[id] = I;
  if (e - s == 1) {
    seg[id] = bp(Fib, a[s]);
    return;
  }
  int mid = (s + e) / 2;
  build(s, mid, 2 * id);
  build(mid, e, 2 * id + 1);
  seg[id] = add(seg[2 * id], seg[2 * id + 1]);
}
void shift(int id) {
  seg[2 * id] = mul(seg[2 * id], lazy[id]);
  seg[2 * id + 1] = mul(seg[2 * id + 1], lazy[id]);
  lazy[2 * id] = mul(lazy[2 * id], lazy[id]);
  lazy[2 * id + 1] = mul(lazy[2 * id + 1], lazy[id]);
  lazy[id] = I;
}
void upd(int l, int r, mat val, int s = 0, int e = n, int id = 1) {
  if (r <= s || e <= l) return;
  if (l <= s && e <= r) {
    seg[id] = mul(seg[id], val);
    lazy[id] = mul(lazy[id], val);
    return;
  }
  shift(id);
  int mid = (s + e) / 2;
  upd(l, r, val, s, mid, 2 * id);
  upd(l, r, val, mid, e, 2 * id + 1);
  seg[id] = add(seg[2 * id], seg[2 * id + 1]);
}
mat get(int l, int r, int s = 0, int e = n, int id = 1) {
  if (r <= s || e <= l) return mat();
  if (l <= s && e <= r) return seg[id];
  shift(id);
  int mid = (s + e) / 2;
  return add(get(l, r, s, mid, 2 * id), get(l, r, mid, e, 2 * id + 1));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int m;
  cin >> n >> m;
  Fib.fib();
  I = mat();
  I.a[1][1] = I.a[0][0] = 1;
  for (int i = 0; i < n; i++) cin >> a[i];
  build();
  for (int i = 0; i < m; i++) {
    int t, l, r;
    cin >> t >> l >> r;
    l--;
    if (t == 1) {
      int x;
      cin >> x;
      mat cur = bp(Fib, x);
      upd(l, r, cur);
    } else
      cout << get(l, r).a[0][1] << "\n";
  }
}
