#include <bits/stdc++.h>
using namespace std;
template <int MOD>
struct ModInt {
  static const int Mod = MOD;
  unsigned x;
  ModInt() : x(0) {}
  ModInt(signed sig) {
    int sigt = sig % MOD;
    if (sigt < 0) sigt += MOD;
    x = sigt;
  }
  ModInt(signed long long sig) {
    int sigt = sig % MOD;
    if (sigt < 0) sigt += MOD;
    x = sigt;
  }
  int get() const { return (int)x; }
  ModInt &operator+=(ModInt that) {
    if ((x += that.x) >= MOD) x -= MOD;
    return *this;
  }
  ModInt &operator-=(ModInt that) {
    if ((x += MOD - that.x) >= MOD) x -= MOD;
    return *this;
  }
  ModInt &operator*=(ModInt that) {
    x = (unsigned long long)x * that.x % MOD;
    return *this;
  }
  ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
  ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
  ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
  ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
  ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
  ModInt inverse() const {
    signed a = x, b = MOD, u = 1, v = 0;
    while (b) {
      signed t = a / b;
      a -= t * b;
      std::swap(a, b);
      u -= t * v;
      std::swap(u, v);
    }
    if (u < 0) u += Mod;
    ModInt res;
    res.x = (unsigned)u;
    return res;
  }
  bool operator==(ModInt that) const { return x == that.x; }
  bool operator!=(ModInt that) const { return x != that.x; }
  ModInt operator-() const {
    ModInt t;
    t.x = x == 0 ? 0 : Mod - x;
    return t;
  }
};
int n;
int m;
struct matrix_A {
  ModInt<1000000007> a[2][2];
  matrix_A() { a[0][0] = a[0][1] = a[1][0] = a[1][1] = 0; }
};
struct matrix_B {
  ModInt<1000000007> a[2];
  matrix_B() { a[0] = a[1] = 0; }
};
namespace math {
namespace fibonacci {
matrix_A mat;
}
}  // namespace math
struct st {
  matrix_A lazy;
  matrix_B sum;
  st() {
    lazy.a[0][0] = lazy.a[1][1] = 1;
    lazy.a[0][1] = lazy.a[1][0] = 0;
  }
  void done() {
    matrix_B nex;
    nex.a[0] = lazy.a[0][0] * sum.a[0] + lazy.a[0][1] * sum.a[1];
    nex.a[1] = lazy.a[1][0] * sum.a[0] + lazy.a[1][1] * sum.a[1];
    sum = nex;
  }
};
st seg[100002 * 4];
matrix_A mult(matrix_A &a, matrix_A &b) {
  matrix_A r;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        r.a[i][j] += a.a[i][k] * b.a[k][j];
      }
    }
  }
  return r;
}
matrix_A ppow(matrix_A a, int n) {
  matrix_A b = a;
  if (n == 1LL) {
    return b;
  }
  n--;
  while (n) {
    if ((n & 1LL)) {
      b = mult(b, a);
    }
    a = mult(a, a);
    n >>= 1LL;
  }
  return b;
}
void update(int b) {
  seg[b].done();
  if (b * 2 + 2 < 100002 * 4) {
    seg[(b << 1) + 1].lazy = mult(seg[(b << 1) + 1].lazy, seg[b].lazy);
    seg[(b << 1) + 2].lazy = mult(seg[(b << 1) + 2].lazy, seg[b].lazy);
  }
  seg[b].lazy.a[0][0] = seg[b].lazy.a[1][1] = 1;
  seg[b].lazy.a[0][1] = seg[b].lazy.a[1][0] = 0;
}
void add(matrix_A &l, matrix_A &r) {
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      l.a[i][j] += r.a[i][j];
    }
  }
}
inline void add(int b, int l, int r, int ll, int rr, matrix_A &x) {
  update(b);
  if (r <= ll || rr <= l) {
    return;
  }
  if (ll <= l && r <= rr) {
    seg[b].lazy = mult(seg[b].lazy, x);
    update(b);
    return;
  }
  add((b << 1) + 1, l, (l + r) >> 1, ll, rr, x);
  add((b << 1) + 2, (l + r) >> 1, r, ll, rr, x);
  seg[b].sum.a[0] = seg[(b << 1) + 1].sum.a[0] + seg[(b << 1) + 2].sum.a[0];
  seg[b].sum.a[1] = seg[(b << 1) + 1].sum.a[1] + seg[(b << 1) + 2].sum.a[1];
}
matrix_B add(matrix_B a, matrix_B b) {
  matrix_B r = a;
  r.a[0] += b.a[0];
  r.a[1] += b.a[1];
  return r;
}
inline matrix_B query(int b, int l, int r, int ll, int rr) {
  update(b);
  if (r <= ll || rr <= l) {
    return matrix_B();
  }
  if (ll <= l && r <= rr) {
    return seg[b].sum;
  }
  return add(query((b << 1) + 1, l, (l + r) >> 1, ll, rr),
             query((b << 1) + 2, (l + r) >> 1, r, ll, rr));
}
inline void init(int b, int l, int r) {
  seg[b].sum.a[0] = 0;
  seg[b].sum.a[1] = r - l;
  if (l + 1 == r) return;
  init(b * 2 + 1, l, (l + r) >> 1);
  init(b * 2 + 2, (l + r) >> 1, r);
}
matrix_A get(int p) {
  math::fibonacci::mat.a[0][0] = 0;
  math::fibonacci::mat.a[0][1] = 1LL;
  math::fibonacci::mat.a[1][0] = 1LL;
  math::fibonacci::mat.a[1][1] = 1LL;
  math::fibonacci::mat = ppow(math::fibonacci::mat, p);
  matrix_A AA;
  AA.a[0][0] = math::fibonacci::mat.a[0][0];
  AA.a[0][1] = math::fibonacci::mat.a[0][1];
  AA.a[1][0] = math::fibonacci::mat.a[1][0];
  AA.a[1][1] = math::fibonacci::mat.a[1][1];
  return AA;
}
ModInt<1000000007> P[100002];
int main() {
  cin >> n >> m;
  init(0, 0, n);
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    P[i] = a;
    if (a > 1) {
      auto f = get(a - 1);
      add(0, 0, n, i, i + 1, f);
    }
  }
  while (m--) {
    int ty;
    scanf("%d", &ty);
    if (ty == 1) {
      int l, r, x;
      scanf("%d%d%d", &l, &r, &x);
      l--;
      r--;
      auto f = get(x);
      add(0, 0, n, l, r + 1, f);
    } else {
      int l, r;
      scanf("%d%d", &l, &r);
      l--;
      r--;
      ModInt<1000000007> ans = query(0, 0, n, l, r + 1).a[1];
      int c = ans.get();
      printf("%d\n", c);
    }
  }
  return 0;
}
