#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7fffffff;
const int N = 1e6 + 5;
inline int read() {
  int x = 0, rev = 0, ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') rev = 1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return rev ? -x : x;
}
int n, ans;
string s = "#";
vector<int> ds = {1};
struct {
  int m;
  int d[N], ds[N], dt[N];
  int nd[N], nds[N], ndt[N];
  void nfy(int* d, int n, int* nd) {
    for (int i = 0; i < n; i++) nd[i] = n;
    for (int i = n - 1; i >= 0; i--) {
      if (i + 1 < n) nd[i] = nd[i + 1];
      if (d[i]) nd[i] = i;
    }
  }
  void init(string& s, const string& t) {
    m = s.size();
    for (int i = 0; i < m; i++) d[i] = s[i] - t[i];
    for (int i = 0; i < m - 1; i++) ds[i] = s[i + 1] - t[i];
    for (int i = 0; i < m - 1; i++) dt[i] = s[i] - t[i + 1];
    nfy(d, m, nd);
    nfy(ds, m - 1, nds);
    nfy(dt, m - 1, ndt);
  }
  int sgn(int x) { return x < 0 ? -1 : 1; }
  int res(int i, int j) {
    int x = min(i, j);
    if (nd[0] < x) return sgn(d[nd[0]]);
    if (i == j) {
      if (i + 1 == m) return 0;
      if (nd[i + 1] == m) return 0;
      return sgn(d[nd[i + 1]]);
    }
    if (i < j) {
      if (nds[i] < j) return sgn(ds[nds[i]]);
      if (j + 1 == m) return 0;
      if (nd[j + 1] == m) return 0;
      return sgn(d[nd[j + 1]]);
    }
    if (ndt[j] < i) return sgn(dt[ndt[j]]);
    if (i + 1 == m) return 0;
    if (nd[i + 1] == m) return 0;
    return sgn(d[nd[i + 1]]);
  }
} cmp[4];
bool cmp1(pair<int, int> p1, pair<int, int> p2) {
  int res = cmp[p1.second * 2 + p2.second].res(p1.first, p2.first);
  if (res) return res < 0;
  return p1.second < p2.second;
}
int main() {
  n = read();
  for (int i = 0; i < n; i++) {
    string t;
    cin >> t;
    t.push_back('#');
    vector<int> dt(t.size());
    while (s.size() < t.size()) s.push_back('#'), ds.push_back(0);
    while (s.size() > t.size()) t.push_back('#'), dt.push_back(0);
    int m = s.size();
    cmp[0].init(s, s), cmp[1].init(s, t), cmp[2].init(t, s), cmp[3].init(t, t);
    vector<pair<int, int> > vp;
    for (int i = 0; i < m; i++)
      vp.push_back(make_pair(i, 0)), vp.push_back(make_pair(i, 1));
    sort(vp.begin(), vp.end(), cmp1);
    int sum = 0;
    for (auto j : vp) {
      int x = j.first, y = j.second;
      if (!y)
        (sum += ds[x]) %= 1000000007;
      else
        (dt[x] += sum) %= 1000000007;
    }
    swap(s, t), swap(ds, dt);
    while (s.size() >= 2 && s[s.size() - 2] == '#') s.pop_back(), ds.pop_back();
  }
  for (auto x : ds) (ans += x) %= 1000000007;
  cout << ans << endl;
  return 0;
}
