#include <bits/stdc++.h>
const int maxn = 1e5 + 100;
const int MOD = 1e9 + 7;
int n, m;
int a[maxn];
void inc(int &a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
struct Matrix {
  int mp[2][2];
  void zero() {
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++) mp[i][j] = 0;
  }
  void one() {
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++) mp[i][j] = i == j;
  }
  bool operator==(const Matrix &A) const {
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++)
        if (mp[i][j] != A.mp[i][j]) return false;
    return true;
  }
  Matrix operator*(const Matrix &A) const {
    Matrix ans;
    ans.zero();
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++)
        for (int k = 0; k < 2; k++)
          inc(ans.mp[i][j], 1ll * mp[i][k] * A.mp[k][j] % MOD);
    return ans;
  }
  Matrix operator+(const Matrix &A) const {
    Matrix ans;
    ans.zero();
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++) ans.mp[i][j] = (mp[i][j] + A.mp[i][j]) % MOD;
    return ans;
  }
} A, E;
Matrix pow_mod(Matrix a, int b) {
  Matrix ans;
  ans.one();
  while (b) {
    if (b & 1) ans = ans * a;
    a = a * a;
    b >>= 1;
  }
  return ans;
}
struct SegmentTree {
  int l, r;
  Matrix sum, lazy;
  void update(Matrix val) {
    sum = sum * val;
    lazy = lazy * val;
  }
} Tree[maxn << 2];
void push_up(int id) {
  Tree[id].sum = Tree[id << 1].sum + Tree[id << 1 | 1].sum;
}
void push_down(int id) {
  Matrix lazy = Tree[id].lazy;
  if (lazy == E) return;
  Tree[id << 1].update(lazy);
  Tree[id << 1 | 1].update(lazy);
  Tree[id].lazy = E;
}
void build(int id, int l, int r) {
  Tree[id].l = l, Tree[id].r = r;
  Tree[id].sum.zero();
  Tree[id].lazy.one();
  if (l == r)
    Tree[id].sum = pow_mod(A, a[l]);
  else {
    int mid = (l + r) >> 1;
    build(id << 1, l, mid);
    build(id << 1 | 1, mid + 1, r);
    push_up(id);
  }
}
void update(int id, int l, int r, Matrix X) {
  int L = Tree[id].l, R = Tree[id].r;
  if (l <= L && R <= r) {
    Tree[id].update(X);
    return;
  }
  push_down(id);
  int mid = (L + R) >> 1;
  if (l <= mid) update(id << 1, l, r, X);
  if (r > mid) update(id << 1 | 1, l, r, X);
  push_up(id);
}
Matrix query(int id, int l, int r) {
  int L = Tree[id].l, R = Tree[id].r;
  if (l <= L && R <= r) return Tree[id].sum;
  push_down(id);
  int mid = (L + R) >> 1;
  Matrix ans;
  ans.zero();
  if (l <= mid) ans = ans + query(id << 1, l, r);
  if (r > mid) ans = ans + query(id << 1 | 1, l, r);
  return ans;
}
int main() {
  A.zero();
  A.mp[0][0] = A.mp[0][1] = A.mp[1][0] = 1;
  E.one();
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  build(1, 1, n);
  while (m--) {
    int op, l, r;
    scanf("%d %d %d", &op, &l, &r);
    if (op == 1) {
      int x;
      scanf("%d", &x);
      Matrix X = pow_mod(A, x);
      update(1, l, r, X);
    } else {
      Matrix res = query(1, l, r);
      printf("%d\n", res.mp[1][0]);
    }
  }
  return 0;
}
