#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
long long a[N];
struct node {
  long long a[3][3];
  node() { memset(a, 0, sizeof(a)); }
  void init() {
    for (int i = 1; i <= 2; i++)
      for (int j = 1; j <= 2; j++) a[i][j] = (i == j);
  }
  node operator+(const node &b) const {
    node c;
    for (int i = 1; i <= 2; i++)
      for (int j = 1; j <= 2; j++)
        c.a[i][j] = (a[i][j] + b.a[i][j]) % 1000000007;
    return c;
  }
  node operator*(const node &b) const {
    node c;
    for (int i = 1; i <= 2; i++)
      for (int k = 1; k <= 2; k++)
        for (int j = 1; j <= 2; j++)
          c.a[i][j] = (c.a[i][j] + 1LL * a[i][k] * b.a[k][j]) % 1000000007;
    return c;
  }
  node operator^(const int &n) const {
    node ans, res;
    ans.init();
    res = (*this);
    long long t = n;
    while (t) {
      if (t & 1) ans = ans * res;
      res = res * res;
      t >>= 1;
    }
    return ans;
  }
} f, s[N * 4], lazy[N * 4];
void pushup(int num) { s[num] = s[num << 1] + s[num << 1 | 1]; }
void pushdown(int num) {
  s[num << 1] = s[num << 1] * lazy[num];
  s[num << 1 | 1] = s[num << 1 | 1] * lazy[num];
  lazy[num << 1] = lazy[num << 1] * lazy[num];
  lazy[num << 1 | 1] = lazy[num << 1 | 1] * lazy[num];
  lazy[num].init();
}
void build(int l, int r, int num) {
  lazy[num].init();
  if (l == r) {
    s[num] = f ^ (a[l] - 1);
    return;
  }
  int mid = (l + r) / 2;
  build(l, mid, num << 1);
  build(mid + 1, r, num << 1 | 1);
  pushup(num);
}
void update(int i, int j, int l, int r, node t, int num) {
  if (l >= i && r <= j) {
    s[num] = t * s[num];
    lazy[num] = lazy[num] * t;
    return;
  }
  pushdown(num);
  int mid = (l + r) / 2;
  if (j <= mid)
    update(i, j, l, mid, t, num << 1);
  else if (i > mid)
    update(i, j, mid + 1, r, t, num << 1 | 1);
  else {
    update(i, mid, l, mid, t, num << 1);
    update(mid + 1, j, mid + 1, r, t, num << 1 | 1);
  }
  pushup(num);
}
long long makesum(int i, int j, int l, int r, int num) {
  if (i <= l && j >= r) return s[num].a[1][1];
  pushdown(num);
  int mid = (l + r) / 2;
  if (j <= mid) return makesum(i, j, l, mid, num << 1);
  if (i > mid) return makesum(i, j, mid + 1, r, num << 1 | 1);
  return (makesum(i, mid, l, mid, num << 1) +
          makesum(mid + 1, j, mid + 1, r, num << 1 | 1)) %
         1000000007;
}
int m, n;
int main() {
  f.a[1][1] = 1;
  f.a[1][2] = 1;
  f.a[2][1] = 1;
  f.a[2][2] = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  build(1, n, 1);
  while (m--) {
    int i, j, k;
    scanf("%d %d %d", &k, &i, &j);
    if (k == 1) {
      int x;
      scanf("%d", &x);
      update(i, j, 1, n, f ^ x, 1);
    } else
      printf("%lld\n", makesum(i, j, 1, n, 1));
  }
  return 0;
}
