#include <bits/stdc++.h>
using namespace std;
const unsigned _mod = 998244353;
const unsigned mod = 1e9 + 7;
const long long infi = 0x3f3f3f3f3f3f3f3fll;
const int inf = 0x3f3f3f3f;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long qpow(long long x, long long y) {
  long long ret = 1;
  while (y) {
    if (y & 1ll) ret = ret * x;
    y >>= 1ll;
    x = x * x;
  }
  return ret;
}
long long ksm(long long x, long long y) {
  long long ret = 1;
  while (y) {
    if (y & 1ll) ret = ret * x % mod;
    y >>= 1ll;
    x = x * x % mod;
  }
  return ret;
}
long long _gcd(long long x, long long y) { return y ? _gcd(y, x % y) : x; }
int n, x, y, f, ans, A[2][1000010], dp[2][1000010], X[1000010], Y[1000010],
    Z[1000010];
string s, t, S[2];
void build() {
  f = (s.size() > t.size() ? s.size() : t.size());
  s.resize(f + 1, '$'), t.resize(f + 1, '$');
  X[f] = Y[f - 1] = Z[f - 1] = 0;
  for (int i = f - 1; i >= 0; --i) X[i] = (s[i] == t[i]) * (X[i + 1] + 1);
  for (int i = f - 2; i >= 0; --i) Y[i] = (s[i] == t[i + 1]) * (Y[i + 1] + 1);
  for (int i = f - 2; i >= 0; --i) Z[i] = (s[i + 1] == t[i]) * (Z[i + 1] + 1);
}
bool cmp(int x, int y) {
  if (x == -1 && y == -1) return (X[0] < f && s[X[0]] < t[X[0]]);
  if (x == -1)
    return (X[0] < y ? s[X[0]] < t[X[0]] : s[Y[y] + y] < t[Y[y] + y + 1]);
  if (y == -1)
    return (X[0] < x ? s[X[0]] < t[X[0]] : s[Z[x] + x + 1] < t[Z[x] + x]);
  if (X[0] < (x < y ? x : y)) return s[X[0]] < t[X[0]];
  if (x <= y && Z[x] < y - x) return s[Z[x] + x + 1] < t[Z[x] + x];
  if (x > y && Y[y] < x - y) return s[Y[y] + y] < t[Y[y] + y + 1];
  int mx = (x > y ? x : y) + 1;
  return s[X[mx] + mx] < t[X[mx] + mx];
}
int main() {
  cin >> n;
  A[0][0] = -1, dp[0][0] = 1;
  if (n == 1) {
    cin >> s;
    return cout << s.size() + 1 << '\n', 0;
  }
  for (int _ = 1; _ <= n; ++_) {
    int x = _ & 1;
    cin >> S[x], s = t = S[x];
    build();
    for (int i = 0; i <= f; ++i) A[x][i] = i - 1;
    sort(A[x], A[x] + f + 1, cmp);
    s = S[x], t = S[x ^ 1];
    build();
    int sum = 0, j = 0;
    for (int i = 0; i <= f; ++i) {
      while (j <= S[x ^ 1].size() && !cmp(A[x][i], A[x ^ 1][j]))
        sum = (sum + dp[x ^ 1][j++]) % mod;
      dp[x][i] = sum;
    }
  }
  for (int i = 0; i <= S[n & 1].size(); ++i) ans = (ans + dp[n & 1][i]) % mod;
  cout << ans << "\n";
  return 0;
}
