#include <bits/stdc++.h>
using namespace std;
int n, m;
int A[100007];
struct mat {
  long long m[2][2];
  mat() { m[0][0] = m[1][0] = m[0][1] = m[1][1] = 0; }
};
pair<long long, long long> sub[2 * (1 << 17)];
mat load[2 * (1 << 17)];
mat operator*(mat &a, mat &b) {
  mat c;
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < 2; ++j) {
      for (int k = 0; k < 2; ++k) {
        c.m[i][j] += a.m[i][k] * b.m[k][j];
      }
      c.m[i][j] %= 1000000007;
    }
  }
  return c;
}
pair<long long, long long> operator*(mat &a, pair<long long, long long> &b) {
  pair<long long, long long> res;
  res.first = (b.first * a.m[0][0] + b.second * a.m[0][1]) % 1000000007;
  res.second = (b.first * a.m[1][0] + b.second * a.m[1][1]) % 1000000007;
  return res;
}
mat pot(mat a, int p) {
  mat res;
  res.m[0][0] = res.m[1][1] = 1;
  for (int i = 0; i < 30; ++i) {
    if (p & (1 << i)) res = res * a;
    a = a * a;
  }
  return res;
}
void build() {
  for (int i = 0; i < 2 * (1 << 17); ++i) {
    load[i].m[0][0] = load[i].m[1][1] = 1;
  }
  for (int i = 1; i <= n; ++i) {
    mat f;
    f.m[0][0] = 1;
    f.m[0][1] = 1;
    f.m[1][0] = 1;
    f = pot(f, A[i] - 1);
    sub[i + (1 << 17)] = make_pair(f.m[0][0], f.m[1][0]);
  }
  for (int i = (1 << 17) - 1; i >= 1; --i) {
    sub[i].first = (sub[2 * i].first + sub[2 * i + 1].first) % 1000000007;
    sub[i].second = (sub[2 * i].second + sub[2 * i + 1].second) % 1000000007;
  }
}
void insert(int a, int b, mat &c, int v = 1, int l = 0, int r = (1 << 17) - 1) {
  if (a > b || a > r || l > b) return;
  if (a <= l && r <= b) {
    load[v] = load[v] * c;
    sub[v] = c * sub[v];
    return;
  }
  insert(a, b, c, 2 * v, l, (l + r) / 2);
  insert(a, b, c, 2 * v + 1, (l + r) / 2 + 1, r);
  sub[v].first = (sub[2 * v].first + sub[2 * v + 1].first) % 1000000007;
  sub[v].second = (sub[2 * v].second + sub[2 * v + 1].second) % 1000000007;
  sub[v] = load[v] * sub[v];
}
pair<long long, long long> query(int a, int b, int v = 1, int l = 0,
                                 int r = (1 << 17) - 1) {
  if (a > b || a > r || l > b) return make_pair(0, 0);
  if (a <= l && r <= b) return sub[v];
  pair<long long, long long> q1 = query(a, b, 2 * v, l, (l + r) / 2),
                             q2 = query(a, b, 2 * v + 1, (l + r) / 2 + 1, r);
  q1 = load[v] * q1;
  q2 = load[v] * q2;
  return make_pair((q1.first + q2.first) % 1000000007,
                   (q1.second + q2.second) % 1000000007);
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> A[i];
  }
  build();
  while (m--) {
    int t, l, r;
    cin >> t >> l >> r;
    if (t == 1) {
      int x;
      cin >> x;
      mat f;
      f.m[0][0] = 1;
      f.m[0][1] = 1;
      f.m[1][0] = 1;
      f = pot(f, x);
      insert(l, r, f);
    } else
      cout << query(l, r).first << '\n';
  }
}
