#include <bits/stdc++.h>
using namespace std;
const int ANSMOD = (int)1e9 + 7;
const int P = 37, MOD = (int)1e9 + 7;
const int N = (int)1e6 + 10;
int f[2][N], pos[2][N], pw[N], n, len[N];
char s[N];
vector<int> a[N], ha[N];
inline void add(int& x, int y) {
  x += y;
  if (x >= ANSMOD) x -= ANSMOD;
}
int hsh(int id, int len, int x) {
  if (!x || len < x)
    return ha[id][len];
  else
    return (1ll * (ha[id][x - 1] - ha[id][x] + MOD) * pw[len - x + 1] +
            ha[id][len + 1]) %
           MOD;
}
bool ok(int s1, int x, int s2, int y) {
  int l = 0, r = min(len[s1] + (!x), len[s2] + (!y));
  for (; l < r - 1;) {
    int mid = (l + r) >> 1;
    if (hsh(s1, mid, x) != hsh(s2, mid, y))
      r = mid;
    else
      l = mid;
  }
  return l + 1 + (!!x) > len[s1] ||
         (l + 1 + (!!y) <= len[s2] &&
          a[s1][!x || l + 1 < x ? l + 1 : l + 2] <=
              a[s2][!y || l + 1 < y ? l + 1 : l + 2]);
}
int main() {
  scanf("%d", &n);
  pw[0] = 1;
  for (int i = 1; i <= 1000000; i++) pw[i] = 1ll * pw[i - 1] * P % MOD;
  for (int i = 1; i <= n; i++) {
    scanf("%s", s);
    len[i] = strlen(s);
    a[i].resize(len[i] + 1);
    ha[i].resize(len[i] + 1);
    for (int j = 1; j <= len[i]; j++) a[i][j] = s[j - 1] - 'a' + 1;
    for (int j = 1; j <= len[i]; j++)
      ha[i][j] = (1ll * ha[i][j - 1] * P + a[i][j]) % MOD;
  }
  for (int i = 1; i <= n; i++) {
    int l = 0, r = len[i] + 2;
    for (int j = 1; j <= len[i]; j++) {
      int k = j;
      char c = a[i][j];
      for (; k <= len[i] && a[i][k] == c; k++)
        ;
      if (k > len[i] || a[i][k] < c)
        for (int p = j; p < k; p++) pos[i & 1][++l] = p;
      else
        for (int p = j; p < k; p++) pos[i & 1][--r] = p;
      j = k - 1;
    }
    pos[i & 1][++l] = 0;
    if (i == 1)
      for (int j = 1; j <= len[i] + 1; j++) f[i & 1][j - 1] = 1;
    else {
      int tmp = 0, sum = 0;
      for (int j = 1; j <= len[i] + 1; j++) {
        for (; tmp < len[i - 1] + 1 &&
               ok(i - 1, pos[(i & 1) ^ 1][tmp + 1], i, pos[i & 1][j]);) {
          tmp++;
          add(sum, f[(i & 1) ^ 1][pos[(i & 1) ^ 1][tmp]]);
        }
        f[i & 1][pos[i & 1][j]] = sum;
      }
    }
  }
  int ans = 0;
  for (int j = 1; j <= len[n] + 1; j++) add(ans, f[n & 1][j - 1]);
  printf("%d\n", ans);
  return 0;
}
