#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const long long maxn = 1e6 + 100;
const long long base = 239;
const long long mod = 1e9 + 7;
long long n, m, k, t;
string S[maxn];
vector<vector<long long> > hsh;
long long stbase[maxn];
long long gethsh(long long i, long long l, long long r) {
  if (r >= S[i].size()) {
    cout << i << " " << l << " " << r << endl;
  }
  long long hsh0 = (hsh[i][r + 1] - hsh[i][l] + mod) % mod;
  hsh0 *= stbase[maxn - 1 - l];
  hsh0 %= mod;
  return hsh0;
}
long long gethsh1(long long i, long long len, long long ind1) {
  if (len <= ind1) {
    return gethsh(i, 0, len - 1);
  }
  long long hsh0 = gethsh(i, 0, ind1 - 1), hsh1 = gethsh(i, ind1 + 1, len);
  long long anshsh = hsh0 + hsh1 * stbase[ind1] % mod;
  anshsh %= mod;
  return anshsh;
}
bool eq(long long i, long long j, long long ind1, long long ind2,
        long long len) {
  long long hsh0, hsh1;
  hsh0 = gethsh1(i, len, ind1);
  hsh1 = gethsh1(j, len, ind2);
  return hsh0 == hsh1;
}
char geti(long long i, long long ind, long long len) {
  if (len <= ind) {
    return S[i][len - 1];
  }
  if (len >= S[i].length()) {
    return char(0);
  }
  return S[i][len];
}
bool les(long long i, long long j, long long ind1, long long ind2) {
  long long L = 0, R = max(S[i].size(), S[j].size()) + 2, M;
  while (R - L > 1) {
    M = (L + R) / 2;
    if (S[i].size() <= M || S[j].size() <= M) {
      R = M;
      continue;
    }
    if (eq(i, j, ind1, ind2, M)) {
      L = M;
    } else {
      R = M;
    }
  }
  return geti(i, ind1, R) < geti(j, ind2, R);
}
long long curi;
bool cmp(long long i, long long j) { return les(curi, curi, i, j); }
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long q, w, e, a, b, c, d;
  stbase[0] = 1;
  for (q = 1; q < maxn; q++) {
    stbase[q] = stbase[q - 1] * base % mod;
  }
  cin >> n;
  vector<vector<long long> > D(n);
  string tr;
  getline(cin, tr);
  D.resize(n);
  hsh.resize(n);
  for (q = 0; q < n; q++) {
    getline(cin, S[q]);
    S[q] += char(0);
    D[q].resize(S[q].size() + 1);
    hsh[q].resize(S[q].size() + 1);
    for (w = 0; w < S[q].size(); w++) {
      hsh[q][w + 1] = hsh[q][w] + (S[q][w] - 'a' + 1) * stbase[w];
      hsh[q][w + 1] %= mod;
    }
  }
  vector<vector<long long> > I(n);
  for (q = 0; q < n; q++) {
    for (w = 0; w < S[q].size(); w++) {
      I[q].push_back(w);
    }
    curi = q;
    sort(I[q].begin(), I[q].end(), cmp);
  }
  for (q = 0; q < S[0].size(); q++) {
    D[0][q] = 1;
  }
  for (q = 1; q < n; q++) {
    long long i = 0, s = 0;
    for (w = 0; w < I[q].size(); w++) {
      long long i1 = I[q][w];
      while (i < I[q - 1].size()) {
        long long j1 = I[q - 1][i];
        if (!les(q, q - 1, i1, j1)) {
          s += D[q - 1][i];
          s %= mod;
          i++;
        } else {
          break;
        }
      }
      D[q][w] = s;
    }
  }
  long long ans = 0;
  for (q = 0; q < D[n - 1].size(); q++) {
    ans += D[n - 1][q];
    ans %= mod;
  }
  cout << ans;
  return 0;
}
