#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFF = 0x3f3f3f3f3f3f3f3fll;
const long long M = 1e9 + 7;
const long long maxn = 1e6 + 107;
const double pi = acos(-1.0);
const double eps = 0.0000000001;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
template <typename T>
inline void pr2(T x, int k = 64) {
  long long i;
  for (i = 0; i < k; i++) fprintf(stderr, "%d", (x >> i) & 1);
  putchar(' ');
}
template <typename T>
inline void add_(T &A, int B, long long MOD = M) {
  A += B;
  (A >= MOD) && (A -= MOD);
}
template <typename T>
inline void mul_(T &A, long long B, long long MOD = M) {
  A = (A * B) % MOD;
}
template <typename T>
inline void mod_(T &A, long long MOD = M) {
  A %= MOD;
  A += MOD;
  A %= MOD;
}
template <typename T>
inline void max_(T &A, T B) {
  (A < B) && (A = B);
}
template <typename T>
inline void min_(T &A, T B) {
  (A > B) && (A = B);
}
template <typename T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
inline long long powMM(long long a, long long b, long long mod = M) {
  long long ret = 1;
  for (; b; b >>= 1ll, a = a * a % mod)
    if (b & 1) ret = ret * a % mod;
  return ret;
}
int startTime;
void startTimer() { startTime = clock(); }
void printTimer() {
  fprintf(stderr, "/--- Time: %ld milliseconds ---/\n", clock() - startTime);
}
char str[maxn], nxt[maxn];
int dpnow[maxn], dpnxt[maxn];
int f1[maxn], f2[maxn], f3[maxn], f4[maxn];
int l[maxn], l_pre[maxn], l_suf[maxn];
int get(int A[], int l, int r) {
  if (l > r) return 0;
  return (A[r] - A[l - 1] + M) % M;
}
int main() {
  int _, i, j;
  int n;
  scanf("%d", &n);
  int lpre, lnow;
  dpnow[1] = 1;
  lpre = lnow = 0;
  for (_ = 1; _ <= n; _++) {
    scanf("%s", nxt + 1);
    lnow = strlen(nxt + 1);
    nxt[lnow + 1] = 1;
    for (i = lnow + 1; i >= 1; i--) {
      if (i > lpre || nxt[i] != str[i + 1])
        l_suf[i] = i;
      else
        l_suf[i] = l_suf[i + 1];
      if (i > lpre || nxt[i] != str[i - 1])
        l_pre[i] = i;
      else
        l_pre[i] = l_pre[i + 1];
      if (i > lpre || nxt[i] != str[i])
        l[i] = i;
      else
        l[i] = l[i + 1];
    }
    auto cmp = [&](int i, int j) {
      if (i == lnow + 1)
        return l[1] < j ? str[l[1]] <= nxt[l[1]]
                        : str[l_suf[j] + 1] <= nxt[l_suf[j]];
      if (j == lnow + 1)
        return l[1] < i ? str[l[1]] <= nxt[l[1]]
                        : str[l_pre[i + 1] - 1] <= nxt[l_pre[i + 1]];
      if (l[1] < min(i, j)) return str[l[1]] <= nxt[l[1]];
      if (i <= j)
        return l_pre[i + 1] - 1 < j ? str[l_pre[i + 1] - 1] <= nxt[l_pre[i + 1]]
                                    : str[l[j + 1]] <= nxt[l[j + 1]];
      if (j < i)
        return l_suf[j] < i ? str[l_suf[j] + 1] <= nxt[l_suf[j]]
                            : str[l[i + 1]] <= nxt[l[i + 1]];
      return false;
    };
    for (i = 1; i <= lnow + 1; i++) {
      dpnxt[i] = 0;
      int low = 0;
      if (i != lnow + 1) low = lpre + 1;
      for (j = low; j <= lpre + 1; j++) {
        if (i != lnow + 1 && j != lpre + 1) continue;
        if (cmp(i, j)) add_(dpnxt[i], dpnow[j]);
      }
    }
    {
      int j;
      for (j = 0; j <= max(lnow + 1, lpre + 1); j++)
        f1[j] = f2[j] = f3[j] = f4[j] = 0;
      for (j = 1; j <= max(lnow + 1, lpre + 1); j++) {
        if (j == lpre + 1) continue;
        if (j <= lpre + 1) f1[j] = dpnow[j];
        if (j <= lpre + 1 && str[l[j + 1]] <= nxt[l[j + 1]]) f2[j] = dpnow[j];
        if (j <= lpre + 1 && str[l_suf[j] + 1] <= nxt[l_suf[j]] && j <= l[1]) {
          int l = max(j + 1, l_suf[j] + 1), r = lnow + 1;
          if (l <= r) {
            add_(f3[l], dpnow[j]);
            add_(f3[r + 1], M - dpnow[j]);
          }
        }
        if (j <= lpre + 1 && j <= l[1]) {
          int l = j + 1, r = min(lnow + 1, l_suf[j]);
          if (l <= r) {
            add_(f4[l], dpnow[j]);
            add_(f4[r + 1], M - dpnow[j]);
          }
        }
      }
      for (j = 1; j <= max(lnow + 1, lpre + 1); j++) {
        add_(f1[j], f1[j - 1]);
        add_(f2[j], f2[j - 1]);
        add_(f3[j], f3[j - 1]);
        add_(f4[j], f4[j - 1]);
      }
    }
    for (i = 1; i <= lnow + 1; i++) {
      if (i == lnow + 1) continue;
      if (l[1] < i && str[l[1]] <= nxt[l[1]])
        add_(dpnxt[i], get(f1, i, lpre + 1));
      if (str[l[1]] <= nxt[l[1]]) add_(dpnxt[i], get(f1, l[1] + 1, i - 1));
      if (i <= l[1] && str[l_pre[i + 1] - 1] <= nxt[l_pre[i + 1]])
        add_(dpnxt[i], get(f1, max(i, l_pre[i + 1]), lpre + 1));
      if (i <= l[1])
        add_(dpnxt[i], get(f2, i, min(lpre + 1, l_pre[i + 1] - 1)));
      add_(dpnxt[i], f3[i]);
      if (str[l[i + 1]] <= nxt[l[i + 1]]) add_(dpnxt[i], f4[i]);
    }
    for (i = 1; i <= lpre + 1; i++) dpnow[i] = str[i] = 0;
    for (i = 1; i <= lnow + 1; i++) dpnow[i] = dpnxt[i], str[i] = nxt[i];
    str[lnow + 1] = 0;
    lpre = lnow;
  }
  int ans = 0;
  for (i = 1; i <= lnow + 1; i++) add_(ans, dpnow[i]);
  printf("%d\n", ans);
}
