#include <bits/stdc++.h>
using namespace std;
const int N = 1000000;
const long long md = (1e9 + 7);
bool need[N];
inline void norm(long long& x) { x %= md; }
struct matr {
  long long a[2][2];
  matr() {
    a[0][0] = a[1][1] = 1;
    a[0][1] = a[1][0] = 0;
  }
  void clear() {
    a[0][0] = a[1][1] = 0;
    a[0][1] = a[1][0] = 0;
  }
  void ed() {
    a[0][0] = a[1][1] = 1;
    a[0][1] = a[1][0] = 0;
  }
};
matr p;
matr pu[N];
long long t[N][2];
matr mult(const matr& a, const matr& b) {
  matr ans;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      ans.a[i][j] = 0;
      for (int k = 0; k < 2; k++) {
        ans.a[i][j] = (ans.a[i][j] + a.a[i][k] * b.a[k][j]) % md;
      }
    }
  }
  return ans;
}
matr sum(const matr& a, const matr& b) {
  matr ans;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      ans.a[i][j] = (a.a[i][j] + b.a[i][j]) % md;
    }
  }
  return ans;
}
matr pw(matr x, long long k) {
  matr ans;
  ans.ed();
  while (k >= 1) {
    if (k & 1LL) {
      ans = mult(ans, x);
    }
    k >>= 1LL;
    x = mult(x, x);
  }
  return ans;
}
void push(int v, int l, int r) {
  if (!need[v]) return;
  if (l != r) {
    pu[v << 1 | 1] = mult(pu[v << 1 | 1], pu[v]);
    need[v << 1 | 1] = 1;
    pu[v << 1] = mult(pu[v << 1], pu[v]);
    need[v << 1] = 1;
  }
  long long t0 = t[v][0], t1 = t[v][1];
  t[v][0] = (pu[v].a[0][0] * t0 + pu[v].a[1][0] * t1) % md;
  t[v][1] = (pu[v].a[0][1] * t0 + pu[v].a[1][1] * t1) % md;
  pu[v].ed();
  need[v] = 0;
}
void build(int v, int l, int r) {
  need[v] = 0;
  pu[v].ed();
  if (l == r) {
    t[v][0] = 0;
    t[v][1] = 1;
    return;
  }
  int c = (l + r) >> 1;
  build(v << 1, l, c);
  build(v << 1 | 1, c + 1, r);
  t[v][0] = (t[v << 1][0] + t[v << 1 | 1][0]) % md;
  t[v][1] = (t[v << 1][1] + t[v << 1 | 1][1]) % md;
}
void add(int ll, int rr, int l, int r, int v, const matr& x) {
  push(v, l, r);
  if (r < ll || rr < l) return;
  if (ll <= l && r <= rr) {
    pu[v] = x;
    need[v] = 1;
    push(v, l, r);
    return;
  }
  int c = (l + r) >> 1;
  add(ll, rr, l, c, v << 1, x);
  add(ll, rr, c + 1, r, v << 1 | 1, x);
  t[v][0] = (t[v << 1][0] + t[v << 1 | 1][0]) % md;
  t[v][1] = (t[v << 1][1] + t[v << 1 | 1][1]) % md;
}
long long get(int ll, int rr, int l, int r, int v) {
  push(v, l, r);
  if (r < ll || rr < l) return 0;
  if (ll <= l && r <= rr) {
    return t[v][1];
  }
  int c = (l + r) >> 1;
  return (get(ll, rr, l, c, v << 1) + get(ll, rr, c + 1, r, v << 1 | 1)) % md;
}
void wr(int v, int l, int r) {
  push(v, l, r);
  if (l == r) {
    cout << t[v][1] << " ";
    return;
  }
  int c = (l + r) >> 1;
  cout << t[v][1] << " ";
  wr(v << 1, l, c);
  wr(v << 1 | 1, c + 1, r);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  p.a[0][0] = 0;
  p.a[0][1] = 1;
  p.a[1][0] = 1;
  p.a[1][1] = 1;
  build(1, 1, n);
  for (int i = 1; i <= n; i++) {
    long long x;
    scanf("%I64d", &x);
    matr temp;
    x--;
    temp = pw(p, x);
    add(i, i, 1, n, 1, temp);
  }
  while (m--) {
    int type, l, r;
    scanf("%d", &type);
    if (type == 1) {
      long long dx;
      scanf("%d%d%I64d", &l, &r, &dx);
      matr temp;
      temp = pw(p, dx);
      add(l, r, 1, n, 1, temp);
    } else {
      scanf("%d%d", &l, &r);
      printf("%I64d\n", get(l, r, 1, n, 1));
    }
  }
}
