#include <bits/stdc++.h>
const int MOD = 1e9 + 7;
struct Matrix {
  int a[2][2];
  Matrix operator+(const Matrix m) const {
    Matrix ret;
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 2; j++) ret.a[i][j] = (a[i][j] + m.a[i][j]) % MOD;
    }
    return ret;
  }
  Matrix operator*(const Matrix m) const {
    Matrix ret;
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 2; j++)
        ret.a[i][j] =
            ((long long)a[i][0] * m.a[0][j] + (long long)a[i][1] * m.a[1][j]) %
            MOD;
    }
    return ret;
  }
} pow2[33], tmp;
Matrix power(int k) {
  Matrix ret = {1, 0, 0, 1};
  for (int i = 0; k; i++, k >>= 1) {
    if (k & 1) ret = ret * pow2[i];
  }
  return ret;
}
void init() {
  pow2[0] = {0, 1, 1, 1};
  for (int i = 1; i <= 30; i++) pow2[i] = pow2[i - 1] * pow2[i - 1];
}
struct Tree {
  bool flag;
  Matrix val, delta;
} tree[1 << 18];
int treeLen;
void pushDown(int i) {
  if (tree[i].flag) {
    tree[2 * i].flag = tree[2 * i + 1].flag = true;
    tree[2 * i].delta = tree[2 * i].delta * tree[i].delta;
    tree[2 * i + 1].delta = tree[2 * i + 1].delta * tree[i].delta;
    tree[2 * i].val = tree[2 * i].val * tree[i].delta;
    tree[2 * i + 1].val = tree[2 * i + 1].val * tree[i].delta;
    tree[i].flag = false;
    tree[i].delta = power(0);
  }
}
void add(int i, int l, int r, int queryL, int queryR) {
  if (l >= queryL && r <= queryR) {
    tree[i] = {true, tree[i].val * tmp, tree[i].delta * tmp};
    return;
  }
  pushDown(i);
  int mid = (l + r) >> 1;
  if (mid >= queryL) add(2 * i, l, mid, queryL, queryR);
  if (mid < queryR) add(2 * i + 1, mid + 1, r, queryL, queryR);
  tree[i].val = tree[2 * i].val + tree[2 * i + 1].val;
}
Matrix query(int i, int l, int r, int queryL, int queryR) {
  if (l >= queryL && r <= queryR) return tree[i].val;
  pushDown(i);
  int mid = (l + r) >> 1;
  Matrix ret = {0, 0, 0, 0};
  if (mid >= queryL) ret = ret + query(2 * i, l, mid, queryL, queryR);
  if (mid < queryR) ret = ret + query(2 * i + 1, mid + 1, r, queryL, queryR);
  return ret;
}
int main() {
  init();
  int n, m, t, op, l, r;
  scanf("%d%d", &n, &m);
  for (treeLen = 1; treeLen < n; treeLen *= 2)
    ;
  for (int i = 0; i < n; i++) {
    scanf("%d", &t);
    tree[treeLen + i] = {false, power(t), power(0)};
  }
  for (int i = treeLen - 1; i; i--)
    tree[i] = {false, tree[2 * i].val + tree[2 * i + 1].val, power(0)};
  while (m--) {
    scanf("%d%d%d", &op, &l, &r);
    if (op == 1) {
      scanf("%d", &t);
      tmp = power(t);
      add(1, 1, treeLen, l, r);
    } else
      printf("%d\n", query(1, 1, treeLen, l, r).a[0][1]);
  }
}
