#include <bits/stdc++.h>
using namespace std;
const int p = 1000000007, N = 100005;
struct mat {
  long long a, b, c, d;
} o = {1, 0, 0, 0}, e = {1, 1, 1, 0}, I = {1, 0, 0, 1};
mat operator+(mat a, mat b) {
  return {(a.a + b.a) % p, (a.b + b.b) % p, (a.c + b.c) % p, (a.d + b.d) % p};
}
mat operator*(mat a, mat b) {
  return {(a.a * b.a + a.b * b.c) % p, (a.a * b.b + a.b * b.d) % p,
          (a.c * b.a + a.d * b.c) % p, (a.c * b.b + a.d * b.d) % p};
}
mat pw(mat x, int y) {
  mat ret = I;
  while (y) {
    if (y & 1) ret = ret * x;
    x = x * x;
    y /= 2;
  }
  return ret;
}
int a[N], b[N];
struct seg {
  mat det, data;
  seg *lc, *rc;
} * rt, pool[N * 2], *tail = pool;
void build(seg *&rt, int l, int r) {
  rt = tail++;
  rt->det = I;
  if (l == r) {
    rt->data = {a[l], b[l], 0, 0};
    return;
  }
  int mid = l + r >> 1;
  build(rt->lc, l, mid);
  build(rt->rc, mid + 1, r);
  rt->data = rt->lc->data + rt->rc->data;
}
void push(seg *rt) {
  rt->lc->data = rt->lc->data * rt->det;
  rt->lc->det = rt->lc->det * rt->det;
  rt->rc->data = rt->rc->data * rt->det;
  rt->rc->det = rt->rc->det * rt->det;
  rt->det = I;
}
void mdf(seg *rt, int l, int r, int L, int R, mat x) {
  if (L <= l && r <= R) {
    rt->data = rt->data * x;
    rt->det = rt->det * x;
    return;
  }
  int mid = l + r >> 1;
  push(rt);
  if (L <= mid) mdf(rt->lc, l, mid, L, R, x);
  if (R > mid) mdf(rt->rc, mid + 1, r, L, R, x);
  rt->data = rt->lc->data + rt->rc->data;
}
long long qry(seg *rt, int l, int r, int L, int R) {
  if (L <= l && r <= R) return rt->data.a;
  int mid = l + r >> 1, ret = 0;
  push(rt);
  if (L <= mid) ret = qry(rt->lc, l, mid, L, R);
  if (R > mid) ret += qry(rt->rc, mid + 1, r, L, R);
  return ret % p;
}
int main() {
  int n, m, i, op, l, r, x;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    if (a[i] == 1) {
      b[i] = 0;
      continue;
    }
    b[i] = (o * pw(e, a[i] - 2)).a;
    a[i] = (o * pw(e, a[i] - 1)).a;
  }
  build(rt, 1, n);
  while (m--) {
    scanf("%d%d%d", &op, &l, &r);
    if (op == 1) {
      scanf("%d", &x);
      mdf(rt, 1, n, l, r, pw(e, x));
    } else
      printf("%I64d\n", qry(rt, 1, n, l, r));
  }
  return 0;
}
