#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
int mod = 1e9 + 7;
int p = 31;
int smax = 1000007;
vector<int> ind1, ind2;
vector<int> nex;
void msor(string s) {
  ind2.resize(s.size() + 1);
  nex.resize(s.size());
  int L = 0, R = s.size();
  nex[s.size() - 1] = s.size();
  for (int i = s.size() - 2; i >= 0; i--) {
    if (s[i] == s[i + 1])
      nex[i] = nex[i + 1];
    else
      nex[i] = i + 1;
  }
  s.push_back('#');
  for (int i = 0; i < s.size() - 2; i++) {
    if (s[i] < s[nex[i]]) {
      ind2[R] = i;
      R--;
    } else {
      ind2[L] = i;
      L++;
    }
  }
  ind2[L] = s.size() - 2;
  ind2[L + 1] = s.size() - 1;
}
vector<unsigned long long> h1, h2;
vector<unsigned long long> stp;
string a, b;
bool cmp(int ind1, int ind2) {
  int L = -1,
      R = min(a.size() - (ind1 < a.size()), b.size() - (ind2 < b.size()));
  while (L < R - 1) {
    int m = (L + R) / 2;
    unsigned long long p1, p2;
    if (ind1 > m)
      p1 = h1[m + 1];
    else
      p1 = (h1[ind1] * stp[m + 1 - ind1]) % mod +
           (h1[m + 2] + mod - (h1[ind1 + 1] * stp[m + 1 - ind1]) % mod) % mod;
    p1 %= mod;
    if (ind2 > m)
      p2 = h2[m + 1];
    else
      p2 = (h2[ind2] * stp[m + 1 - ind2]) % mod +
           (h2[m + 2] + mod - (h2[ind2 + 1] * stp[m + 1 - ind2]) % mod) % mod;
    p2 %= mod;
    if (p1 == p2)
      L = m;
    else
      R = m;
  }
  if (ind1 == a.size()) ind1++;
  if (ind2 == b.size()) ind2++;
  if ((R >= ind1 ? R + 1 : R) > a.size()) return 1;
  if ((R >= ind2 ? R + 1 : R) > b.size()) return 0;
  return a[R >= ind1 ? R + 1 : R] <= b[R >= ind2 ? R + 1 : R];
}
bool cmp2(int ind1, int ind2) {
  string a1 = a, b1 = b;
  a1.erase(a1.begin() + ind1);
  b1.erase(b1.begin() + ind2);
  return a1 <= b1;
}
void calch(string s) {
  h2.resize(s.size() + 1);
  h2[0] = 0;
  for (int i = 0; i < s.size(); i++) {
    h2[i + 1] = (h2[i] * p + (s[i] - 'a' + 1)) % mod;
  }
}
void solve() {
  int n;
  cin >> n;
  cin >> a;
  vector<unsigned long long> dp1(a.size() + 1, 1), dp2;
  msor(a);
  ind1 = ind2;
  calch(a);
  h1 = h2;
  for (int i = 1; i < n; i++) {
    cin >> b;
    msor(b);
    calch(b);
    dp2.resize(b.size() + 1);
    fill(dp2.begin(), dp2.end(), 0);
    int L = 0, R = 0;
    while (R < ind2.size() && L < ind1.size()) {
      if (cmp2(ind1[L], ind2[R]) != cmp(ind1[L], ind2[R])) {
        cout << "no";
      }
      if (cmp(ind1[L], ind2[R])) {
        dp2[R] = (dp2[R] + dp1[L]) % mod;
        L++;
      } else {
        R++;
        if (R < ind2.size()) dp2[R] = dp2[R - 1];
      }
    }
    R++;
    while (R < ind2.size()) {
      dp2[R] = dp2[R - 1];
      R++;
    }
    dp1 = dp2;
    ind1 = ind2;
    a = b;
    h1 = h2;
  }
  unsigned long long ans = 0;
  for (unsigned long long i : dp1) {
    ans = (ans + i) % mod;
  }
  cout << ans;
}
int main() {
  stp.resize(smax);
  stp[0] = 1;
  for (int i = 1; i < smax; i++) {
    stp[i] = (stp[i - 1] * p) % mod;
  }
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
  for (int t = 0; t < 1000000; t++) {
    a = "", b = "";
    for (int i = 0; i < rand() % 6 + 1; i++) {
      a += rand() % 2 + 'a';
    }
    for (int i = 0; i < rand() % 5 + 1; i++) {
      b += rand() % 2 + 'a';
    }
    int inda = rand() % (a.size() + 1);
    int indb = rand() % (b.size() + 1);
    calch(a);
    h1 = h2;
    calch(b);
    if (cmp(inda, indb) != cmp2(inda, indb)) {
      cout << t << '\n';
      cout << a << ' ' << inda << '\n';
      cout << b << ' ' << indb << '\n';
    }
  }
}
