#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e5 + 5;
const long long MAXC = 1e6 + 5;
const long long hmod[2] = {(long long)1e9 + 7, (long long)1e9 + 9};
const long long ALFABET[2] = {29, 31};
const long long mod = 1e9 + 7;
long long dp[2][MAXC];
vector<long long> pot[2];
vector<long long> H[2][MAXN];
vector<long long> nast[MAXN];
vector<long long> sorted[MAXN];
long long pom[MAXC];
string s[MAXN];
long long ans = 0;
long long fastpow(long long a, long long b, long long wsk) {
  long long wynik = 1;
  if (a == 0) return 0;
  while (b) {
    if (b & 1) wynik = (wynik * a) % hmod[wsk];
    a = (a * a) % hmod[wsk];
    b >>= 1;
  }
  return wynik;
}
long long inv(long long x, long long wsk) {
  return fastpow(x, hmod[wsk] - 2, wsk);
}
long long add(long long a, long long b) {
  a += b;
  while (a >= mod) a -= mod;
  return a;
}
long long sub(long long a, long long b) {
  a -= b;
  while (a < 0) a += mod;
  return a;
}
long long gethash(long long r, long long pos, long long wsk, long long id) {
  if (r < pos) return (H[wsk][id][r] * pot[wsk][MAXC - 1 - r]) % hmod[wsk];
  long long haha = (long long)H[wsk][id].size() - 1;
  long long part1 = H[wsk][id][pos - 1];
  long long part2 = H[wsk][id][min(haha, r + 1)] - H[wsk][id][pos];
  while (part2 < 0) part2 += hmod[wsk];
  part2 *= inv(ALFABET[wsk], wsk);
  long long Hasz = (part1 + part2) % hmod[wsk];
  Hasz = (Hasz * pot[wsk][MAXC - 1 - r]) % hmod[wsk];
  return Hasz;
}
char wez(long long ktora, long long pos, long long id) {
  if (ktora < pos) return s[id][ktora - 1];
  if (ktora + 1 <= (long long)s[id].size()) return s[id][ktora];
  return '0';
}
bool check(long long id1, long long lit1, long long id2, long long lit2) {
  lit1 = sorted[id1][lit1];
  lit2 = sorted[id2][lit2];
  long long len1 = (long long)s[id1].size();
  long long len2 = (long long)s[id2].size();
  long long ip = 0, ik = min(len1, len2) + 1;
  while (ip + 1 < ik) {
    long long mid = (ip + ik) >> 1;
    if (gethash(mid, lit1, 0, id1) == gethash(mid, lit2, 0, id2) &&
        gethash(mid, lit1, 1, id1) == gethash(mid, lit2, 1, id2))
      ip = mid;
    else
      ik = mid;
  }
  return wez(ip + 1, lit1, id1) <= wez(ip + 1, lit2, id2);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  for (long long i = 0; i < 2; i++) {
    pot[i].resize(MAXC);
    pot[i][0] = 1;
    for (long long j = 1; j <= MAXC - 1; j++) {
      pot[i][j] = (pot[i][j - 1] * ALFABET[i]) % hmod[i];
    }
  }
  for (long long i = 1; i <= n; i++) {
    cin >> s[i];
    for (long long j = 0; j < 2; j++) {
      H[j][i].resize((long long)s[i].size() + 1);
      H[j][i][0] = 0;
      for (long long k = 1; k <= (long long)s[i].size(); k++) {
        H[j][i][k] =
            (H[j][i][k - 1] + pot[j][k] * (s[i][k - 1] - 'a' + 1)) % hmod[j];
      }
    }
    nast[i].resize((long long)s[i].size() + 1);
    nast[i][(long long)s[i].size()] = (long long)s[i].size();
    for (long long k = (long long)s[i].size() - 1; k >= 1; k--) {
      if (s[i][k - 1] != s[i][k]) {
        nast[i][k] = k + 1;
      } else
        nast[i][k] = nast[i][k + 1];
    }
    long long l = 1, r = (long long)s[i].size();
    for (long long k = 1; k <= (long long)s[i].size(); k++) {
      if (s[i][k - 1] < s[i][nast[i][k] - 1])
        pom[r--] = k;
      else
        pom[l++] = k;
    }
    long long wsk = 0;
    sorted[i].resize((long long)s[i].size() + 2);
    for (long long k = 1; k <= (long long)s[i].size(); k++) {
      sorted[i][++wsk] = pom[k];
      if (pom[k] == (long long)s[i].size())
        sorted[i][++wsk] = (long long)s[i].size() + 1;
    }
  }
  for (long long i = 1; i <= (long long)s[1].size() + 1; i++) {
    dp[1][i] = 1;
  }
  for (long long i = 2; i <= n; i++) {
    long long sum = 0;
    long long wsk = 0;
    long long rak1 = i % 2;
    long long rak2 = (i % 2) ^ 1;
    for (long long j = 0; j < (long long)s[i].size() + 2; j++) dp[i % 2][j] = 0;
    for (long long j = 1; j <= (long long)s[i].size() + 1; j++) {
      while (wsk + 1 <= (long long)s[i - 1].size() + 1 &&
             check(i - 1, wsk + 1, i, j)) {
        sum = (sum + dp[rak2][wsk + 1]) % mod;
        wsk++;
      }
      dp[rak1][j] = sum;
    }
  }
  long long rak1 = n % 2;
  for (long long i = 1; i <= (long long)s[n].size() + 1; i++)
    ans = (ans + dp[rak1][i]) % mod;
  cout << ans;
  return 0;
}
