#include <bits/stdc++.h>
using namespace std;
const int mod = (int)1e9 + 7;
const int inf = (1 << 30) - 1;
const int N = 1e5 + 5;
struct num {
  int a, b;
  num() : a(), b() {}
  num(int x) : a(x % mod), b() {}
  num(int a, int b) : a(a % mod), b(b % mod) {}
  bool operator==(const num &n) const { return a == n.a && b == n.b; }
  num operator+(const num &n) const { return num(a + n.a, b + n.b); }
  num operator-(const num &n) const {
    return num(a - n.a + mod, b - n.b + mod);
  }
  num operator*(const num &n) const {
    return num((long long)a * n.a % mod + 5ll * b % mod * n.b % mod,
               (long long)a * n.b % mod + (long long)b * n.a % mod);
  }
  void operator*=(const num &n) {
    long long A = (long long)a * n.a % mod + 5ll * b % mod * n.b % mod;
    long long B = (long long)a * n.b % mod + (long long)b * n.a % mod;
    this->a = A % mod;
    this->b = B % mod;
  }
  num const operator%(int mod) const { return num(a, b); }
};
int binpow(int a, int n, int mod) {
  int res = 1;
  while (n) {
    if (n & 1) res = (long long)res * a % mod;
    a = (long long)a * a % mod;
    n >>= 1;
  }
  return res;
}
num binpow(num a, int n, int mod) {
  num res = num(1, 0);
  while (n) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
const int s5 = binpow(5, mod - 2, mod);
const int s2 = binpow(2, mod - 2, mod);
const num A = num(0, s5);
const num B = num(0, mod - s5);
const num E = num(1, 0);
const num Z = num(0, 0);
const num C[2] = {num(s2, s2), num(s2, mod - s2)};
num f[N][2], toMult[2][4 * N], sum[2][4 * N];
int n, m;
void build(int v, int l, int r) {
  if (l == r) {
    for (int i = 0; i < 2; i++) sum[i][v] = f[l][i], toMult[i][v] = E;
    return;
  }
  build(v + v, l, ((l + r) >> 1));
  build(v + v + 1, ((l + r) >> 1) + 1, r);
  for (int i = 0; i < 2; i++) {
    sum[i][v] = sum[i][v + v] + sum[i][v + v + 1];
    toMult[i][v] = E;
  }
}
void push(int v) {
  if (toMult[0][v] == E) return;
  for (int i = 0; i < 2; i++) {
    if (v + v < 4 * N) toMult[i][v + v] *= toMult[i][v];
    if (v + v + 1 < 4 * N) toMult[i][v + v + 1] *= toMult[i][v];
    sum[i][v] *= toMult[i][v];
    toMult[i][v] = E;
  }
}
void update(int v, int l, int r, int L, int R, num x[2]) {
  push(v);
  if (R < l || r < L) return;
  if (L <= l && r <= R) {
    for (int i = 0; i < 2; i++) toMult[i][v] *= x[i];
    push(v);
    return;
  }
  update(v + v, l, ((l + r) >> 1), L, R, x);
  update(v + v + 1, ((l + r) >> 1) + 1, r, L, R, x);
  for (int i = 0; i < 2; i++) sum[i][v] = sum[i][v + v] + sum[i][v + v + 1];
}
int get(int v, int l, int r, int L, int R) {
  push(v);
  if (R < l || r < L) return 0;
  if (L <= l && r <= R) {
    num res = sum[0][v] + sum[1][v];
    assert(res.b == 0);
    return res.a;
  }
  return (get(v + v, l, ((l + r) >> 1), L, R) +
          get(v + v + 1, ((l + r) >> 1) + 1, r, L, R)) %
         mod;
}
void print(int v, int l, int r, int tab = 0) {
  for (int i = 0; i < tab; i++) putchar('\t');
  printf("[%d %d] sum=%d\n", l, r, (sum[0][v].a + sum[1][v].a) % mod);
  if (l == r) return;
  print(v + v, l, ((l + r) >> 1), tab + 1);
  print(v + v + 1, ((l + r) >> 1) + 1, r, tab + 1);
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1, x; i <= n; i++) {
    scanf("%d", &x);
    x %= mod - 2;
    f[i][0] = A * binpow(C[0], x, mod);
    f[i][1] = B * binpow(C[1], x, mod);
  }
  build(1, 1, n);
  int ty, l, r, x;
  for (int i = 0; i < m; i++) {
    scanf("%d %d %d", &ty, &l, &r);
    if (ty == 1) {
      scanf("%d", &x);
      x %= mod - 2;
      num qx[2] = {binpow(C[0], x, mod), binpow(C[1], x, mod)};
      update(1, 1, n, l, r, qx);
    } else {
      printf("%d\n", get(1, 1, n, l, r));
    }
  }
  return 0;
}
