#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long z) {
  long long ret = 1;
  while (y > 0) {
    if (y & 1) ret = (ret * x) % z;
    x = (x * x) % z;
    y >>= 1;
  }
  return ret;
}
const long long NN = 2, MOD = 1e9 + 7, N = 1e5 + 5;
long long sz = 2, m = MOD, A[N];
class matrix {
 public:
  long long mat[NN][NN];
  matrix() {
    for (int i = 0; i < NN; i++)
      for (int j = 0; j < NN; j++) mat[i][j] = 0;
  }
  inline matrix operator*(const matrix &a) {
    matrix temp;
    for (int i = 0; i < sz; i++)
      for (int j = 0; j < sz; j++) {
        for (int k = 0; k < sz; k++) {
          temp.mat[i][j] += (mat[i][k] * a.mat[k][j]) % m;
          if (temp.mat[i][j] >= m) temp.mat[i][j] -= m;
        }
      }
    return temp;
  }
  inline matrix operator+(const matrix &a) {
    matrix temp;
    for (int i = 0; i < sz; i++)
      for (int j = 0; j < sz; j++) {
        temp.mat[i][j] = mat[i][j] + a.mat[i][j];
        if (temp.mat[i][j] >= m) temp.mat[i][j] -= m;
      }
    return temp;
  }
  inline matrix operator-(const matrix &a) {
    matrix temp;
    for (int i = 0; i < sz; i++)
      for (int j = 0; j < sz; j++) {
        temp.mat[i][j] = mat[i][j] - a.mat[i][j];
        if (temp.mat[i][j] < m) temp.mat[i][j] += m;
      }
    return temp;
  }
  inline void operator=(const matrix &b) {
    for (int i = 0; i < sz; i++)
      for (int j = 0; j < sz; j++) mat[i][j] = b.mat[i][j];
  }
};
matrix T[N << 2], L[N << 2], fib, iden, temp;
matrix pow(matrix a, long long k) {
  matrix ans;
  for (int i = 0; i < sz; i++) ans.mat[i][i] = 1;
  while (k) {
    if (k & 1) ans = ans * a;
    a = a * a;
    k >>= 1;
  }
  return ans;
}
void build(long long node, long long lo, long long hi) {
  L[node] = iden;
  if (lo == hi) {
    T[node] = pow(fib, A[lo]);
    return;
  }
  long long mid = (lo + hi) >> 1;
  build(node << 1, lo, mid);
  build(node << 1 | 1, mid + 1, hi);
  T[node] = T[node << 1] + T[node << 1 | 1];
}
void push(long long node, long long lo, long long hi) {
  T[node] = T[node] * L[node];
  if (lo != hi) {
    L[node << 1] = L[node << 1] * L[node];
    L[node << 1 | 1] = L[node << 1 | 1] * L[node];
  }
  L[node] = iden;
  return;
}
void update(long long node, long long lo, long long hi, long long l,
            long long r, matrix &temp) {
  push(node, lo, hi);
  if (lo > r || hi < l) return;
  if (lo >= l && hi <= r) {
    L[node] = L[node] * temp;
    push(node, lo, hi);
    return;
  }
  long long mid = (lo + hi) >> 1;
  update(node << 1, lo, mid, l, r, temp);
  update(node << 1 | 1, mid + 1, hi, l, r, temp);
  T[node] = T[node << 1] + T[node << 1 | 1];
  return;
}
long long query(long long node, long long lo, long long hi, long long l,
                long long r) {
  if (lo > r || hi < l) return 0;
  push(node, lo, hi);
  if (lo >= l && hi <= r) return T[node].mat[1][0];
  long long mid = (lo + hi) >> 1;
  return (query(node << 1, lo, mid, l, r) +
          query(node << 1 | 1, mid + 1, hi, l, r)) %
         MOD;
}
int main() {
  long long n, m;
  fib.mat[0][1] = fib.mat[1][0] = fib.mat[1][1] = 1;
  iden.mat[0][0] = iden.mat[1][1] = 1;
  scanf("%lld%lld", &n, &m);
  for (long long i = 1; i <= n; ++i) scanf("%lld", &A[i]);
  build(1, 1, n);
  while (m--) {
    long long ty, l, r, x;
    scanf("%lld%lld%lld", &ty, &l, &r);
    if (ty == 1) {
      scanf("%lld", &x);
      temp = pow(fib, x);
      update(1, 1, n, l, r, temp);
    } else {
      printf("%lld\n", query(1, 1, n, l, r));
    }
  }
  return 0;
}
