#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
template <typename T>
inline void Add(T &x, T y) {
  x += y;
  if (x >= mod) x -= mod;
}
template <typename T>
inline void Mul(T &x, T y) {
  (x *= y) %= mod;
}
inline int read() {
  int x = 0;
  char ch = getchar();
  bool f = 0;
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = 1;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    x = (x << 3) + (x << 1) + (ch ^ 48);
  return f ? -x : x;
}
struct matrix {
  long long a[2][2];
  matrix() { memset(a, 0, sizeof(a)); }
  inline bool isI() {
    return a[0][0] == 1 && a[1][1] == 1 && a[0][1] == 0 && a[1][0] == 0;
  }
  friend inline matrix operator*(const matrix &A, const matrix &B) {
    matrix C;
    for (int i = (0), end_i = (1); i <= end_i; i++)
      for (int j = (0), end_i = (1); j <= end_i; j++)
        for (int k = (0), end_i = (1); k <= end_i; k++)
          Add(C.a[i][j], A.a[i][k] * B.a[k][j] % mod);
    return C;
  }
  friend inline matrix operator+(const matrix &A, const matrix &B) {
    matrix C;
    for (int i = (0), end_i = (1); i <= end_i; i++)
      for (int j = (0), end_i = (1); j <= end_i; j++)
        C.a[i][j] = (A.a[i][j] + B.a[i][j]) % mod;
    return C;
  }
} I, F;
inline matrix Pow(matrix A, long long n) {
  matrix B = I;
  for (; n; n >>= 1, A = A * A)
    if (n & 1) B = B * A;
  return B;
}
int n;
matrix sum[200010 << 2], tag[200010 << 2];
inline void pushdown(int u) {
  if (tag[u].isI()) return;
  sum[u << 1] = sum[u << 1] * tag[u];
  sum[u << 1 | 1] = sum[u << 1 | 1] * tag[u];
  tag[u << 1] = tag[u << 1] * tag[u];
  tag[u << 1 | 1] = tag[u << 1 | 1] * tag[u];
  tag[u] = I;
}
inline void pushup(int u) { sum[u] = sum[u << 1] + sum[u << 1 | 1]; }
void add(int L, int R, const matrix &C, int u = 1, int l = 1, int r = n) {
  if (L <= l && r <= R) {
    tag[u] = tag[u] * C, sum[u] = sum[u] * C;
    return;
  }
  int mid = l + r >> 1;
  pushdown(u);
  if (L <= mid) add(L, R, C, u << 1, l, mid);
  if (mid < R) add(L, R, C, u << 1 | 1, mid + 1, r);
  pushup(u);
}
matrix ask(int L, int R, int u = 1, int l = 1, int r = n) {
  if (L <= l && r <= R) return sum[u];
  pushdown(u);
  int mid = l + r >> 1;
  matrix ans;
  if (L <= mid) ans = ans + ask(L, R, u << 1, l, mid);
  if (mid < R) ans = ans + ask(L, R, u << 1 | 1, mid + 1, r);
  return ans;
}
int m;
int main() {
  I.a[0][0] = I.a[1][1] = 1;
  F.a[0][0] = 1, F.a[0][1] = 1;
  F.a[1][0] = 1;
  F.a[1][1] = 0;
  n = read();
  m = read();
  for (int i = (1), end_i = (n << 2); i <= end_i; i++) tag[i] = I, sum[i] = I;
  int opt, l, r, x;
  matrix B;
  for (int i = (1), end_i = (n); i <= end_i; i++)
    B = Pow(F, read() - 1), add(i, i, B);
  for (int _ = (1), end_i = (m); _ <= end_i; _++) {
    opt = read(), l = read(), r = read();
    if (opt == 1)
      add(l, r, Pow(F, read()));
    else
      printf("%d\n", ask(l, r).a[0][0]);
  }
  return 0;
}
