#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int MAXN = 1e5 + 100;
struct Mat {
  long long mat[2][2];
};
struct node {
  int l, r, lazy;
  Mat tag;
  Mat sum;
} seg[MAXN * 4];
Mat operator*(Mat a, Mat b) {
  Mat c;
  memset(c.mat, 0, sizeof(c.mat));
  int i, j, k;
  for (k = 0; k < 2; ++k) {
    for (i = 0; i < 2; ++i) {
      for (j = 0; j < 2; ++j) {
        c.mat[i][j] = (c.mat[i][j] + a.mat[i][k] * b.mat[k][j]) % mod;
      }
    }
  }
  return c;
}
Mat operator+(Mat a, Mat b) {
  Mat c;
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) c.mat[i][j] = (a.mat[i][j] + b.mat[i][j]) % mod;
  return c;
}
Mat operator^(Mat a, long long k) {
  Mat c;
  int i, j;
  for (i = 0; i < 2; ++i)
    for (j = 0; j < 2; ++j) c.mat[i][j] = (i == j);
  for (; k; k >>= 1) {
    if (k & 1) c = c * a;
    a = a * a;
  }
  return c;
}
long long a[MAXN];
Mat f, I, tmp;
void build(int i, int l, int r) {
  seg[i].l = l, seg[i].r = r, seg[i].tag = I;
  if (l == r) {
    seg[i].sum = f ^ (a[l] - 1);
    return;
  }
  int m = (l + r) / 2;
  build(i * 2, l, m);
  build(i * 2 + 1, m + 1, r);
  seg[i].sum = seg[i * 2].sum + seg[i * 2 + 1].sum;
}
void push_down(int i) {
  if (seg[i].l != seg[i].r) {
    seg[i * 2].tag = seg[i * 2].tag * seg[i].tag;
    seg[i * 2].sum = seg[i * 2].sum * seg[i].tag;
    seg[i * 2 + 1].tag = seg[i * 2 + 1].tag * seg[i].tag;
    seg[i * 2 + 1].sum = seg[i * 2 + 1].sum * seg[i].tag;
  }
  seg[i].tag = I;
}
void update(int i, int l, int r) {
  if (seg[i].l == l && seg[i].r == r) {
    seg[i].sum = seg[i].sum * tmp;
    seg[i].tag = seg[i].tag * tmp;
    return;
  }
  int m = (seg[i].l + seg[i].r) / 2;
  push_down(i);
  if (r <= m)
    update(i * 2, l, r);
  else if (l > m)
    update(i * 2 + 1, l, r);
  else {
    update(i * 2, l, m);
    update(i * 2 + 1, m + 1, r);
  }
  seg[i].sum = seg[i * 2].sum + seg[i * 2 + 1].sum;
  return;
}
Mat query(int i, int l, int r) {
  int m = (seg[i].l + seg[i].r) / 2;
  if (seg[i].l == l && seg[i].r == r) {
    return seg[i].sum;
  }
  push_down(i);
  if (r <= m)
    return query(i * 2, l, r);
  else if (m < l)
    return query(i * 2 + 1, l, r);
  else
    return query(i * 2, l, m) + query(i * 2 + 1, m + 1, r);
}
int main() {
  f.mat[0][0] = 0;
  f.mat[0][1] = f.mat[1][0] = f.mat[1][1] = 1;
  I.mat[0][0] = I.mat[1][1] = 1, I.mat[0][1] = I.mat[1][0] = 0;
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  build(1, 1, n);
  while (m--) {
    int op, l, r;
    scanf("%d%d%d", &op, &l, &r);
    if (op == 1) {
      long long v;
      scanf("%I64d", &v);
      tmp = f ^ v;
      update(1, l, r);
    } else {
      long long ans;
      Mat res = query(1, l, r);
      ans = (res.mat[0][0] + res.mat[1][0]) % mod;
      printf("%I64d\n", ans);
    }
  }
  return 0;
}
