#include <bits/stdc++.h>
inline int fp(int x, int k) {
  int res = 1;
  for (; k; k >>= 1, x = 1ll * x * x % 1000000007)
    if (k & 1) res = 1ll * res * x % 1000000007;
  return res;
}
int n, m;
char str[1000005];
std::vector<int> s[100005];
std::vector<int> pos[100005], nxt;
const int X = 37, iX = fp(X, 1000000007 - 2);
std::vector<int> hsh[100005];
std::vector<int> f[100005];
inline void init(int x) {
  f[x].resize(s[x].size());
  pos[x].resize(s[x].size());
  nxt.resize(s[x].size());
  hsh[x].resize(s[x].size());
  nxt[s[x].size() - 1] = s[x].size() - 1;
  for (int i = s[x].size() - 2; i >= 0; i--)
    nxt[i] = s[x][i] == s[x][i + 1] ? nxt[i + 1] : i + 1;
  int l = 0, r = s[x].size() - 1;
  for (int i = 0; i < s[x].size(); i++)
    if (s[x][i] > s[x][nxt[i]])
      pos[x][l++] = i;
    else
      pos[x][r--] = i;
  hsh[x][0] = s[x][0];
  for (int i = 1, tmp = X; i < s[x].size();
       i++, tmp = 1ll * tmp * X % 1000000007)
    hsh[x][i] = (hsh[x][i - 1] + 1ll * s[x][i] * tmp % 1000000007) % 1000000007;
}
inline int gethsh(int x, int i, int j) {
  return j < i ? hsh[x][j]
               : (1ll * (hsh[x][j + 1] - hsh[x][i] + 1000000007) * iX %
                      1000000007 +
                  (i ? hsh[x][i - 1] : 0)) %
                     1000000007;
}
inline bool cmp(int x, int i, int y, int j) {
  int l = 0, r = std::min(s[x].size(), s[y].size()) - 2, k = 0;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (gethsh(x, i, mid) == gethsh(y, j, mid)) {
      k = mid + 1;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  if (k == std::min(s[x].size(), s[y].size()) - 1)
    return s[x].size() <= s[y].size() ||
           (s[x].size() - 1 == s[y].size() && j == s[y].size() - 1 &&
            i < s[x].size() - 1);
  return s[x][k + (k >= i)] < s[y][k + (k >= j)];
}
int ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", str);
    m = strlen(str);
    for (int j = 0; j < m; j++) s[i].push_back(str[j] - 'a' + 2);
    s[i].push_back(1);
    init(i);
  }
  for (int i = 0; i < s[1].size(); i++) f[1][i] = 1;
  for (int i = 2; i <= n; i++) {
    for (int j = 0, k = 0, tmp = 0; j < s[i].size(); j++) {
      while (k < s[i - 1].size() && cmp(i - 1, pos[i - 1][k], i, pos[i][j])) {
        tmp = (tmp + f[i - 1][pos[i - 1][k]]) % 1000000007;
        k++;
      }
      f[i][pos[i][j]] = tmp;
    }
  }
  for (int i = 0; i < s[n].size(); i++)
    ans = (ans + f[n][i] % 1000000007) % 1000000007;
  printf("%d\n", ans);
}
