#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
struct Matrix {
  long long a[3][3];
  void init() {
    a[1][1] = 1;
    a[1][2] = 1;
    a[2][1] = 1;
    a[2][2] = 0;
  }
  void identity() {
    a[1][1] = 1;
    a[2][2] = 1;
    a[1][2] = 0;
    a[2][1] = 0;
  }
  void print() {
    for (int i = 1; i < 3; i++) {
      for (int k = 1; k < 3; k++) {
        cout << a[i][k] << " ";
      }
      cout << endl;
    }
  }
};
Matrix operator*(const Matrix &a1, const Matrix &a2) {
  Matrix z;
  z.a[1][1] = a1.a[1][1] * a2.a[1][1] + a1.a[1][2] * a2.a[2][1];
  z.a[1][1] %= mod;
  z.a[2][1] = a1.a[1][1] * a2.a[1][2] + a1.a[1][2] * a2.a[2][2];
  z.a[1][2] %= mod;
  z.a[1][2] = a1.a[2][1] * a2.a[1][1] + a1.a[2][2] * a2.a[2][1];
  z.a[2][1] %= mod;
  z.a[2][2] = a1.a[2][1] * a2.a[1][2] + a1.a[2][2] * a2.a[2][2];
  z.a[2][2] %= mod;
  return z;
}
Matrix operator%(Matrix &a1, long long x) {
  for (int i = 0; i < 3; i++) {
    for (int k = 0; k < 3; k++) {
      a1.a[i][k] %= mod;
    }
  }
  return a1;
}
pair<long long, long long> operator+(pair<long long, long long> p1,
                                     pair<long long, long long> p2) {
  p1.first += p2.first;
  p1.second += p2.second;
  p1.first %= mod;
  p1.second %= mod;
  return p1;
}
Matrix binPower(long long x) {
  x -= 2;
  Matrix ans;
  ans.a[1][1] = 1;
  ans.a[1][2] = 0;
  ans.a[2][1] = 0;
  ans.a[2][2] = 1;
  if (x == -1) ans.a[2][2] = 0;
  Matrix base;
  base.init();
  while (x > 0) {
    if (x & 1) {
      ans = ans * base;
      ans = ans % mod;
    }
    base = base * base;
    base = base % mod;
    x /= 2;
  }
  return ans;
}
pair<long long, long long> s[400100];
int n;
long long a[200100];
Matrix lazy[400100];
pair<long long, long long> arr[400200];
void build(int id = 1, int l = 0, int r = n) {
  if (r - l < 2) {
    s[id] = arr[l];
    s[id].first %= mod;
    s[id].second %= mod;
    return;
  }
  int mid = (l + r) / 2;
  build(id * 2, l, mid);
  build(id * 2 + 1, mid, r);
  s[id] = s[id * 2] + s[id * 2 + 1];
  s[id].first %= mod;
  s[id].second %= mod;
}
void upd(int id, int l, int r, Matrix x) {
  lazy[id] = lazy[id] * x;
  lazy[id] = lazy[id] % mod;
  long long temp1 = s[id].first;
  s[id].first = x.a[1][1] * s[id].first + x.a[1][2] * s[id].second;
  s[id].second = x.a[2][1] * temp1 + x.a[2][2] * s[id].second;
  s[id].first %= mod;
  s[id].second %= mod;
}
void shift(int id, int l, int r) {
  int mid = (l + r) / 2;
  upd(id * 2, l, mid, lazy[id]);
  upd(id * 2 + 1, mid, r, lazy[id]);
  lazy[id].identity();
}
void increase(int x, int y, Matrix v, int id = 1, int l = 0, int r = n) {
  if (x >= r or l >= y) return;
  if (x <= l && r <= y) {
    upd(id, l, r, v);
    return;
  }
  shift(id, l, r);
  int mid = (l + r) / 2;
  increase(x, y, v, id * 2, l, mid);
  increase(x, y, v, id * 2 + 1, mid, r);
  s[id] = s[id * 2] + s[id * 2 + 1];
  s[id].first %= mod;
  s[id].second %= mod;
}
pair<long long, long long> sum(int x, int y, int id = 1, int l = 0, int r = n) {
  if (x >= r or l >= y) return make_pair(0, 0);
  if (x <= l && r <= y) return s[id];
  shift(id, l, r);
  int mid = (l + r) / 2;
  pair<long long, long long> ans =
      sum(x, y, id * 2, l, mid) + sum(x, y, id * 2 + 1, mid, r);
  ans.first %= mod;
  ans.second %= mod;
  return ans;
}
int main(int argc, char **argv) {
  for (int i = 0; i < 200100; i++) {
    lazy[i].identity();
  }
  cin >> n;
  int m;
  cin >> m;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    a[i] = x;
  }
  for (int i = 0; i < n; i++) {
    Matrix temp;
    temp = binPower(a[i]);
    arr[i].first = temp.a[1][1] + temp.a[1][2];
    arr[i].second = temp.a[2][1] + temp.a[2][2];
  }
  build();
  while (m--) {
    int t, l, r, x;
    scanf("%d%d%d", &t, &l, &r);
    if (t == 1) {
      scanf("%d", &x);
      x += 2;
      l--;
      Matrix b = binPower(x);
      b = b % mod;
      increase(l, r, b);
    } else {
      l--;
      printf("%d\n", sum(l, r).first);
    }
  }
  return 0;
}
