#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int maxn = 200200;
struct mat {
  long long a, b;
  mat(long long A = 0, long long B = 0) : a(A), b(B) {}
  bool isIdentity() const { return a == 1 && b == 0; }
  mat operator+(const mat &rhs) const {
    return mat((a + rhs.a) % MOD, (b + rhs.b) % MOD);
  }
  mat operator*(const mat &rhs) const {
    return mat((a * rhs.a + b * rhs.b) % MOD,
               (a * rhs.b + b * (rhs.a + rhs.b)) % MOD);
  }
  mat power(long long b) const {
    mat a = *this, ans(1, 0);
    while (b) {
      if (b & 1) ans = ans * a;
      b >>= 1;
      a = a * a;
    }
    return ans;
  }
};
struct node {
  int l, r, mid;
  mat val, cov;
  node *lc, *rc;
  void mkd(const mat &pw) {
    val = val * pw;
    cov = cov * pw;
  }
  void pdown() {
    if (l != r && !cov.isIdentity()) {
      lc->mkd(cov);
      rc->mkd(cov);
      cov = mat(1, 0);
    }
  }
  void update() { val = lc->val + rc->val; }
  mat sum(int sl, int sr) {
    pdown();
    if (sl == l && sr == r) return val;
    if (sr <= mid) return lc->sum(sl, sr);
    if (sl > mid) return rc->sum(sl, sr);
    return lc->sum(sl, mid) + rc->sum(mid + 1, sr);
  }
  void pwd(int sl, int sr, int pw) {
    pdown();
    if (sl == l && sr == r) return mkd(mat(0, 1).power(pw));
    if (sr <= mid) return lc->pwd(sl, sr, pw), update();
    if (sl > mid) return rc->pwd(sl, sr, pw), update();
    lc->pwd(sl, mid, pw);
    rc->pwd(mid + 1, sr, pw);
    update();
  }
} pool[maxn], *pcnt = pool, *rt;
int ival[maxn];
node *build(int L, int R) {
  node *a = pcnt++;
  a->l = L;
  a->r = R;
  a->mid = (L + R) / 2;
  a->cov = mat(1, 0);
  if (L == R) {
    a->lc = a->rc = NULL;
    a->val = mat(0, 1).power(ival[L] - 1);
  } else {
    a->lc = build(L, a->mid);
    a->rc = build(a->mid + 1, R);
    a->update();
  }
  return a;
}
int main() {
  int n, M;
  scanf("%d%d", &n, &M);
  for (int i = 1; i <= n; ++i) scanf("%d", ival + i);
  rt = build(1, n);
  while (M--) {
    int t, l, r, x;
    scanf("%d%d%d", &t, &l, &r);
    if (t == 1) {
      scanf("%d", &x);
      rt->pwd(l, r, x);
    } else {
      mat ans = rt->sum(l, r);
      printf("%d\n", int((ans.a + ans.b) % MOD));
    }
  }
  return 0;
}
