#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
pair<pair<int, int>, pair<int, int> > identity, fib;
inline pair<pair<int, int>, pair<int, int> > mult(
    pair<pair<int, int>, pair<int, int> >& a,
    pair<pair<int, int>, pair<int, int> >& b) {
  return {{((long long)a.first.first * (long long)b.first.first +
            (long long)a.first.second * (long long)b.second.first) %
               MOD,
           ((long long)a.first.first * (long long)b.first.second +
            (long long)a.first.second * (long long)b.second.second) %
               MOD},
          {((long long)a.second.first * (long long)b.first.first +
            (long long)a.second.second * (long long)b.second.first) %
               MOD,
           ((long long)a.second.first * (long long)b.first.second +
            (long long)a.second.second * (long long)b.second.second) %
               MOD}};
}
inline pair<pair<int, int>, pair<int, int> > add(
    pair<pair<int, int>, pair<int, int> >& a,
    pair<pair<int, int>, pair<int, int> >& b) {
  return {{(a.first.first + b.first.first) % MOD,
           (a.first.second + b.first.second) % MOD},
          {(a.second.first + b.second.first) % MOD,
           (a.second.second + b.second.second) % MOD}};
}
pair<pair<int, int>, pair<int, int> > binpow(
    pair<pair<int, int>, pair<int, int> > a, long long deg) {
  if (deg == 0ll) return identity;
  if (deg & 1ll) {
    pair<pair<int, int>, pair<int, int> > b = binpow(a, deg ^ 1ll);
    return mult(a, b);
  }
  a = binpow(a, deg >> 1ll);
  return mult(a, a);
}
int n, m, a[100105];
int tp, first, second, z;
char pis[400105];
pair<pair<int, int>, pair<int, int> > t[400105], p[400105];
void build(int v, int tl, int tr) {
  pis[v] = false;
  p[v] = identity;
  if (tl == tr) {
    t[v] = binpow(fib, a[tl]);
  } else {
    int tm = (tl + tr) >> 1;
    build(v + v, tl, tm);
    build(v + v + 1, tm + 1, tr);
    t[v] = add(t[v + v], t[v + v + 1]);
  }
}
inline void push(int v, int tl, int tr) {
  if (pis[v]) {
    t[v] = mult(t[v], p[v]);
    if (tl != tr) {
      pis[v + v] = pis[v + v + 1] = 1;
      p[v + v] = mult(p[v + v], p[v]);
      p[v + v + 1] = mult(p[v + v + 1], p[v]);
    }
    pis[v] = 0;
    p[v] = identity;
  }
}
pair<pair<int, int>, pair<int, int> > val;
void update(int v, int tl, int tr, int l, int r) {
  if (l > r) return;
  push(v, tl, tr);
  if (tl == l && tr == r) {
    pis[v] = 1;
    p[v] = val;
    push(v, tl, tr);
    return;
  }
  int tm = (tl + tr) >> 1;
  update(v + v, tl, tm, l, min(r, tm));
  update(v + v + 1, tm + 1, tr, max(l, tm + 1), r);
  push(v + v, tl, tm);
  push(v + v + 1, tm + 1, tr);
  t[v] = add(t[v + v], t[v + v + 1]);
}
int get(int v, int tl, int tr, int l, int r) {
  if (l > r) return 0;
  push(v, tl, tr);
  if (tl == l && tr == r) {
    return (t[v].first.first + t[v].first.second) % MOD;
  }
  int tm = (tl + tr) >> 1;
  return (get(v + v, tl, tm, l, min(r, tm)) +
          get(v + v + 1, tm + 1, tr, max(l, tm + 1), r)) %
         MOD;
}
int main() {
  identity = {{1, 0}, {0, 1}};
  fib = {{0, 1}, {1, 1}};
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    --a[i];
  }
  build(1, 0, n - 1);
  while (m--) {
    cin >> tp >> first >> second;
    --first;
    --second;
    if (tp == 1) {
      cin >> z;
      val = binpow(fib, z);
      update(1, 0, n - 1, first, second);
    } else {
      cout << get(1, 0, n - 1, first, second) << "\n";
    }
  }
  return 0;
}
