#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
struct vec {
  long long x[2];
  vec() {
    x[0] = 0;
    x[1] = 0;
  }
  vec(long long x, long long y) {
    this->x[0] = x;
    this->x[1] = y;
  }
  long long &operator[](int i) { return x[i]; }
};
struct mat {
  long long A[2][2];
  mat() { A[0][0] = A[0][1] = A[1][0] = A[1][1] = 0; }
  mat(long long a1, long long a2, long long a3, long long a4) {
    A[0][0] = a1;
    A[0][1] = a2;
    A[1][0] = a3;
    A[1][1] = a4;
  }
  long long *operator[](int i) { return A[i]; }
};
const int K = 1 << 16;
const long long b = K - 1;
mat F[4][K], id(1, 0, 0, 1);
mat operator*(mat A, mat B) {
  mat C;
  for (int i = 0; i < 2; ++i)
    for (int k = 0; k < 2; ++k)
      for (int j = 0; j < 2; ++j) C[i][j] += A[i][k] * B[k][j];
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 2; ++j) C[i][j] %= MOD;
  return C;
}
mat &operator*=(mat &A, mat B) { return A = A * B; }
vec operator*(mat A, vec v) {
  vec b;
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < 2; ++j) b[i] += A[i][j] * v[j];
    b[i] %= MOD;
  }
  return b;
}
vec operator+(vec v, vec b) {
  return vec((v[0] + b[0]) % MOD, (v[1] + b[1]) % MOD);
}
mat Fpow(long long x) {
  int k = 0;
  mat ans = id;
  while (x) {
    ans *= F[k++][x & b];
    x >>= 16;
  }
  return ans;
}
vec fib(long long n) { return Fpow(n - 1) * vec(1, 0); }
const int MAXN = 1e5;
long long A[MAXN], L[MAXN << 2];
vec ST[MAXN << 2];
int N, M;
void build(int n, int l, int r) {
  if (l == r) {
    ST[n] = fib(A[l]);
    return;
  }
  build(n << 1, l, (l + r) / 2);
  build(n << 1 | 1, (l + r) / 2 + 1, r);
  ST[n] = ST[n << 1] + ST[n << 1 | 1];
}
void build() { return build(1, 0, N - 1); }
vec query(int n, int l, int r, int i, int j) {
  if (r < i || j < l) return vec(0, 0);
  if (L[n] != 0) {
    ST[n] = Fpow(L[n]) * ST[n];
    if (l != r) {
      L[n << 1] += L[n];
      L[n << 1 | 1] += L[n];
    }
    L[n] = 0;
  }
  if (i <= l && r <= j) return ST[n];
  return query(n << 1, l, (l + r) / 2, i, j) +
         query(n << 1 | 1, (l + r) / 2 + 1, r, i, j);
}
long long query(int i, int j) { return query(1, 0, N - 1, i, j)[0]; }
void update(int n, int l, int r, int i, int j, long long x) {
  if (L[n] != 0) {
    ST[n] = Fpow(L[n]) * ST[n];
    if (l != r) {
      L[n << 1] += L[n];
      L[n << 1 | 1] += L[n];
    }
    L[n] = 0;
  }
  if (r < i || j < l) return;
  if (i <= l && r <= j) {
    ST[n] = Fpow(x) * ST[n];
    if (l != r) {
      L[n << 1] += x;
      L[n << 1 | 1] += x;
    }
    return;
  }
  update(n << 1, l, (l + r) / 2, i, j, x);
  update(n << 1 | 1, (l + r) / 2 + 1, r, i, j, x);
  ST[n] = ST[n << 1] + ST[n << 1 | 1];
}
void update(int i, int j, long long x) { return update(1, 0, N - 1, i, j, x); }
int main() {
  F[0][0] = id;
  F[0][1] = mat(1, 1, 1, 0);
  for (int k = 2; k < K; ++k) F[0][k] = F[0][k - 1] * F[0][1];
  for (int i = 1; i < 4; ++i) {
    F[i][0] = id;
    F[i][1] = F[i - 1][K - 1] * F[i - 1][1];
    for (int k = 2; k < K; ++k) F[i][k] = F[i][k - 1] * F[i][1];
  }
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> N >> M;
  for (int i = 0; i < N; ++i) cin >> A[i];
  build();
  while (M--) {
    int t, l, r;
    cin >> t >> l >> r;
    --l;
    --r;
    if (t == 1) {
      long long x;
      cin >> x;
      update(l, r, x);
    } else
      cout << query(l, r) << '\n';
  }
  return 0;
}
