#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int s = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) s = s * 10 + ch - '0', ch = getchar();
  return s;
}
const int N = 1000005, mod = 1e9 + 7;
int prime[] = {998244353, 998244853, 1000000007, 1000000009};
int n, p, mod1, mod2, base = 131;
char s[N];
long long pw1[N], pw2[N];
vector<long long> h1[N], h2[N], G[N], pre[N];
vector<char> S[N];
inline long long qpow(long long a, long long b, long long mod) {
  long long res = 1;
  for (; b; b >>= 1, a = a * a % mod)
    if (b & 1) res = res * a % mod;
  return res;
}
inline pair<long long, long long> check(int i, int x, int p) {
  pair<long long, long long> p1;
  if (p < x || x == 0)
    p1 = {h1[i][p], h2[i][p]};
  else {
    p1.first =
        (h1[i][x - 1] * pw1[p + 1 - x] % mod1 +
         (h1[i][p + 1] - h1[i][x] * pw1[p + 1 - x] % mod1 + mod1) % mod1) %
        mod1;
    p1.second =
        (h2[i][x - 1] * pw2[p + 1 - x] % mod2 +
         (h2[i][p + 1] - h2[i][x] * pw2[p + 1 - x] % mod2 + mod2) % mod2) %
        mod2;
  }
  return p1;
}
inline bool cmp(int i, int x, int j, int y) {
  int R = min(G[i].size() - (x != 0), G[j].size() - (y != 0)) - 1;
  int l = 1, r = R, res = 0;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(i, x, mid) == check(j, y, mid))
      l = mid + 1, res = mid;
    else
      r = mid - 1;
  }
  if (res == R)
    return G[i].size() - (x != 0) <= G[j].size() - (y != 0);
  else {
    char t1, t2;
    if (x == 0 || res + 1 < x)
      t1 = S[i][res + 1];
    else
      t1 = S[i][res + 2];
    if (y == 0 || res + 1 < y)
      t2 = S[j][res + 1];
    else
      t2 = S[j][res + 2];
    return t1 <= t2;
  }
}
inline bool comp(int x, int y) { return cmp(p, x, p, y); }
void init() {
  int len = strlen(s + 1);
  h1[p].resize(len + 1), h2[p].resize(len + 1), G[p].resize(len + 1),
      S[p].resize(len + 1), pre[p].resize(len + 1);
  for (int i = 1; i <= len; i++) {
    h1[p][i] = (h1[p][i - 1] * base % mod1 + s[i] - 'a' + 1) % mod1;
    h2[p][i] = (h2[p][i - 1] * base % mod2 + s[i] - 'a' + 1) % mod2;
    G[p][i] = i;
    S[p][i] = s[i];
  }
  stable_sort(G[p].begin(), G[p].end(), comp);
}
int main() {
  srand(time(0));
  pw1[0] = 1, pw2[0] = 1;
  n = read();
  mod1 = prime[rand() % 2], mod2 = prime[rand() % 2 + 2];
  for (int i = 1; i < N; i++)
    pw1[i] = pw1[i - 1] * base % mod1, pw2[i] = pw2[i - 1] * base % mod2;
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    p = i;
    init();
  }
  for (int i = 0; i < pre[1].size(); i++) pre[1][i] = i + 1;
  for (int i = 2; i <= n; i++) {
    int k = -1;
    for (int t = 0; t < G[i].size(); t++) {
      int j = G[i][t];
      while (k + 1 < G[i - 1].size() && cmp(i - 1, G[i - 1][k + 1], i, j)) k++;
      if (k != -1) pre[i][t] = pre[i - 1][k];
    }
    for (int t = 1; t < G[i].size(); t++)
      pre[i][t] = (pre[i][t] + pre[i][t - 1]) % mod;
  }
  printf("%lld", pre[n].back());
  return 0;
}
