#include <bits/stdc++.h>
using namespace std;
template <typename TH>
void _dbg(const char* sdbg, TH h) {
  cerr << sdbg << "=" << h << "\n";
}
template <typename TH, typename... TA>
void _dbg(const char* sdbg, TH h, TA... t) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << "=" << h << ",";
  _dbg(sdbg + 1, t...);
}
template <class C>
void mini(C& a4, C b4) {
  a4 = min(a4, b4);
}
template <class C>
void maxi(C& a4, C b4) {
  a4 = max(a4, b4);
}
template <class T1, class T2>
ostream& operator<<(ostream& out, pair<T1, T2> pair) {
  return out << "(" << pair.first << ", " << pair.second << ")";
}
template <class A, class B, class C>
struct Triple {
  A first;
  B second;
  C third;
  bool operator<(const Triple& t) const {
    if (first != t.first) return first < t.first;
    if (second != t.second) return second < t.second;
    return third < t.third;
  }
};
template <class T>
void ResizeVec(T&, vector<long long>) {}
template <class T>
void ResizeVec(vector<T>& vec, vector<long long> sz) {
  vec.resize(sz[0]);
  sz.erase(sz.begin());
  if (sz.empty()) {
    return;
  }
  for (T& v : vec) {
    ResizeVec(v, sz);
  }
}
template <class A, class B, class C>
ostream& operator<<(ostream& out, Triple<A, B, C> t) {
  return out << "(" << t.first << ", " << t.second << ", " << t.third << ")";
}
template <class T>
ostream& operator<<(ostream& out, vector<T> vec) {
  out << "(";
  for (auto& v : vec) out << v << ", ";
  return out << ")";
}
const long long P = 1e9 + 7;
struct Matrix {
  long long a[4];
  long long& operator[](long long i) { return a[i]; }
};
Matrix Id() { return {1, 0, 0, 1}; }
Matrix Mult(Matrix a, Matrix b) {
  Matrix m;
  m[0] = (a[0] * b[0] + a[1] * b[2]) % P;
  m[1] = (a[0] * b[1] + a[1] * b[3]) % P;
  m[2] = (a[2] * b[0] + a[3] * b[2]) % P;
  m[3] = (a[2] * b[1] + a[3] * b[3]) % P;
  return m;
}
Matrix Add(Matrix a, Matrix b) {
  Matrix m;
  for (long long i = 0; i < (4); ++i) {
    m[i] = (a[i] + b[i]) % P;
  }
  return m;
}
const long long M = (1 << 17);
pair<Matrix, Matrix> drz[2 * M + 5];
Matrix spow(Matrix m, long long b) {
  Matrix r = Id();
  while (b) {
    if (b % 2) {
      r = Mult(r, m);
    }
    m = Mult(m, m);
    b /= 2;
  }
  return r;
}
Matrix Sum(long long a) { return Mult(drz[a].first, drz[a].second); }
void Upd(long long a) {
  if (a >= M) {
    return;
  }
  drz[a].first = Add(Sum(2 * a), Sum(2 * a + 1));
}
void Mult(long long a, long long b, Matrix m) {
  a += M - 1;
  b += M - 1;
  drz[a].second = Mult(drz[a].second, m);
  if (a != b) {
    drz[b].second = Mult(drz[b].second, m);
  }
  while (a) {
    if (a / 2 != b / 2) {
      if (a % 2 == 0) {
        drz[a + 1].second = Mult(drz[a + 1].second, m);
      }
      if (b % 2 == 1) {
        drz[b - 1].second = Mult(drz[b - 1].second, m);
      }
    }
    Upd(a);
    if (a != b) {
      Upd(b);
    }
    a /= 2;
    b /= 2;
  }
}
long long Read(long long a, long long b) {
  a += M - 1;
  b += M - 1;
  Matrix l = Id();
  Matrix r{0, 0, 0, 0};
  if (a != b) {
    r = Id();
  }
  while (a) {
    l = Mult(l, drz[a].second);
    r = Mult(r, drz[b].second);
    if (a / 2 != b / 2) {
      if (a % 2 == 0) {
        l = Add(l, Sum(a + 1));
      }
      if (b % 2 == 1) {
        r = Add(r, Sum(b - 1));
      }
    }
    a /= 2;
    b /= 2;
  }
  Matrix s = Add(l, r);
  (s[0], s[1], s[2], s[3]);
  return s[1];
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  if (0) cout << fixed << setprecision(10);
  cin.tie(0);
  for (long long i = 0; i < (2 * M + 5); ++i) {
    drz[i].first = drz[i].second = Id();
  }
  for (long long i = (M - 1); i >= (1); --i) {
    Upd(i);
  }
  long long n, m;
  cin >> n >> m;
  Matrix fib{1, 1, 1, 0};
  for (long long i = (1); i <= (n); ++i) {
    long long a;
    cin >> a;
    Mult(i, i, spow(fib, a));
  }
  for (long long i = (1); i <= (m); ++i) {
    long long t, l, r;
    cin >> t >> l >> r;
    if (t == 1) {
      long long x;
      cin >> x;
      Mult(l, r, spow(fib, x));
    } else {
      cout << Read(l, r) << "\n";
    }
  }
  return 0;
}
