#include <bits/stdc++.h>
using namespace std;
const int N = 100005, MOD = 1000000007;
int a[N];
struct mat {
  long long f[2][2];
  mat() { memset(f, 0, sizeof f); }
  mat(int _q, int _w, int _e, int _r) {
    f[0][0] = _q;
    f[0][1] = _w;
    f[1][0] = _e;
    f[1][1] = _r;
  }
  mat operator+(mat a) {
    mat c;
    for (int i = (0); i < (2); i++)
      for (int j = (0); j < (2); j++) c.f[i][j] = (f[i][j] + a.f[i][j]) % MOD;
    return c;
  }
  mat operator*(mat a) {
    mat c;
    for (int i = (0); i < (2); i++)
      for (int j = (0); j < (2); j++)
        for (int k = (0); k < (2); k++)
          c.f[i][j] = (c.f[i][j] + f[i][k] * a.f[k][j]) % MOD;
    return c;
  }
  mat operator^(long long n) {
    if (n == 0) return mat(1, 1, 1, 0);
    if (n == 1) return (*this);
    mat c = (*this) ^ (n / 2);
    c = c * c;
    return (n & 1) ? c * (*this) : c;
  }
};
struct stree {
  struct {
    mat c, lz = mat(1, 0, 0, 1);
  } t[N * 4];
  void lz_upd(int node) {
    mat v = t[node].lz;
    t[(node << 1)].lz = t[(node << 1)].lz * v;
    t[(node << 1)].c = t[(node << 1)].c * v;
    t[((node << 1) | 1)].lz = t[((node << 1) | 1)].lz * v;
    t[((node << 1) | 1)].c = t[((node << 1) | 1)].c * v;
    t[node].lz = mat(1, 0, 0, 1);
  }
  void build(int node, int l, int r) {
    if (l == r) {
      t[node].c = mat(1, 1, 1, 0) ^ a[l];
      return;
    }
    build((node << 1), l, ((l + r) >> 1));
    build(((node << 1) | 1), ((l + r) >> 1) + 1, r);
    t[node].c = t[(node << 1)].c + t[((node << 1) | 1)].c;
  }
  void update(int node, int l, int r, int u, int v, mat x) {
    if (u > r || v < l) return;
    if (l >= u && r <= v) {
      t[node].lz = t[node].lz * x;
      t[node].c = t[node].c * x;
      return;
    }
    lz_upd(node);
    update((node << 1), l, ((l + r) >> 1), u, v, x);
    update(((node << 1) | 1), ((l + r) >> 1) + 1, r, u, v, x);
    t[node].c = t[(node << 1)].c + t[((node << 1) | 1)].c;
  }
  int ask(int node, int l, int r, int u, int v) {
    if (u > r || v < l) return 0;
    if (l >= u && r <= v) return t[node].c.f[0][1];
    lz_upd(node);
    return (ask((node << 1), l, ((l + r) >> 1), u, v) +
            ask(((node << 1) | 1), ((l + r) >> 1) + 1, r, u, v)) %
           MOD;
  }
};
stree it;
int main() {
  int n, m, t, x, y, v;
  scanf("%d%d", &n, &m);
  for (int i = (1); i < (n + 1); i++) scanf("%d", &a[i]);
  it.build(1, 1, n);
  while (m--) {
    scanf("%d%d%d", &t, &x, &y);
    if (t == 1) {
      scanf("%d", &v);
      it.update(1, 1, n, x, y, mat(1, 1, 1, 0) ^ v);
    } else {
      printf("%d\n", it.ask(1, 1, n, x, y));
    }
  }
  return 0;
}
