#include <bits/stdc++.h>
using namespace std;
std::mt19937 rnd(
    (int)std::chrono::steady_clock::now().time_since_epoch().count());
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 100000;
const int MAXSUMLEN = 1000000;
const int MOD = 1000000007;
void inc(int& a, int b) {
  if ((a += b) >= MOD) a -= MOD;
}
void dec(int& a, int b) { inc(a, MOD - b); }
int n;
char s[MAXSUMLEN + 1];
int offset[MAXN + 1], len[MAXN];
int dpnorem[MAXN];
int dprem[MAXSUMLEN];
char a[MAXSUMLEN + 1];
int alen;
char b[MAXSUMLEN + 1];
int blen;
int dpa[MAXSUMLEN];
int dpb[MAXSUMLEN];
int prefixcmp[MAXSUMLEN + 1];
int suffixcmp[MAXSUMLEN + 1][3];
int prefsubdp[MAXSUMLEN + 1][3];
int suffsubdp[MAXSUMLEN + 1][3];
int combinecmp(int a, int b) { return a != 0 ? a : b; }
int cmpchar(int aidx, int bidx) {
  char ca = 0 <= aidx && aidx < alen ? a[aidx] : '\0',
       cb = 0 <= bidx && bidx < blen ? b[bidx] : '\0';
  return ca < cb ? -1 : ca > cb ? +1 : 0;
}
int solve() {
  dpnorem[n - 1] = 1;
  for (int j = (0); j < (len[n - 1]); ++j) dprem[offset[n - 1] + j] = 1;
  for (int i = n - 2; i >= 0; --i) {
    alen = len[i];
    for (int j = (0); j < (alen); ++j) a[j] = s[offset[i] + j];
    a[alen] = '\0';
    blen = len[i + 1];
    for (int k = (0); k < (blen); ++k) b[k] = s[offset[i + 1] + k];
    b[blen] = '\0';
    for (int k = (0); k < (blen); ++k) dpb[k] = dprem[offset[i + 1] + k];
    int mxlen = max(alen, blen);
    prefixcmp[0] = 0;
    for (int j = (0); j < (mxlen); ++j)
      prefixcmp[j + 1] = combinecmp(prefixcmp[j], cmpchar(j, j));
    for (int shift = (-1); shift <= (+1); ++shift) {
      suffixcmp[mxlen][shift + 1] = 0;
      for (int j = mxlen - 1; j >= 0; --j)
        suffixcmp[j][shift + 1] =
            combinecmp(cmpchar(j, j + shift), suffixcmp[j + 1][shift + 1]);
    }
    for (int j = (0); j < (mxlen); ++j) {
      for (int cmp = (-1); cmp <= (+1); ++cmp) prefsubdp[j][cmp + 1] = 0;
      if (j - 1 >= 0)
        for (int prefcmp = (-1); prefcmp <= (+1); ++prefcmp) {
          int cmp = combinecmp(prefcmp, cmpchar(j - 1, j));
          inc(prefsubdp[j][cmp + 1], prefsubdp[j - 1][prefcmp + 1]);
        }
      if (j < blen) {
        int cmp = prefixcmp[j];
        inc(prefsubdp[j][cmp + 1], dpb[j]);
      }
    }
    for (int j = mxlen - 1; j >= 0; --j) {
      for (int cmp = (-1); cmp <= (+1); ++cmp) suffsubdp[j][cmp + 1] = 0;
      if (j + 1 < mxlen)
        for (int suffcmp = (-1); suffcmp <= (+1); ++suffcmp) {
          int cmp = combinecmp(cmpchar(j + 1, j), suffcmp);
          inc(suffsubdp[j][cmp + 1], suffsubdp[j + 1][suffcmp + 1]);
        }
      if (j < blen) {
        int cmp = suffixcmp[j + 1][0 + 1];
        inc(suffsubdp[j][cmp + 1], dpb[j]);
      }
    }
    dpnorem[i] = 0;
    if (suffixcmp[0][0 + 1] <= 0) inc(dpnorem[i], dpnorem[i + 1]);
    for (int k = (0); k < (blen); ++k) {
      int cmp = combinecmp(prefixcmp[k], suffixcmp[k][+1 + 1]);
      if (cmp <= 0) inc(dpnorem[i], dpb[k]);
    }
    for (int j = (0); j < (alen); ++j) {
      dpa[j] = 0;
      for (int prefcmp = (-1); prefcmp <= (+1); ++prefcmp) {
        int cmp = combinecmp(prefcmp, suffixcmp[j + 1][0 + 1]);
        if (cmp <= 0) inc(dpa[j], prefsubdp[j][prefcmp + 1]);
      }
      for (int suffcmp = (-1); suffcmp <= (+1); ++suffcmp) {
        int cmp = combinecmp(prefixcmp[j], suffcmp);
        if (cmp <= 0) inc(dpa[j], suffsubdp[j][suffcmp + 1]);
      }
      if (j < blen) {
        int cmp = combinecmp(prefixcmp[j], suffixcmp[j + 1][0 + 1]);
        if (cmp <= 0) dec(dpa[j], dpb[j]);
      }
      {
        int cmp = combinecmp(prefixcmp[j], suffixcmp[j + 1][-1 + 1]);
        if (cmp <= 0) inc(dpa[j], dpnorem[i + 1]);
      }
    }
    for (int j = (0); j < (alen); ++j) dprem[offset[i] + j] = dpa[j];
  }
  int ret = 0;
  inc(ret, dpnorem[0]);
  for (int j = (0); j < (len[0]); ++j) inc(ret, dprem[offset[0] + j]);
  return ret;
}
void run() {
  scanf("%d", &n);
  offset[0] = 0;
  for (int i = (0); i < (n); ++i) {
    scanf("%s", s + offset[i]);
    len[i] = strlen(s + offset[i]);
    offset[i + 1] = offset[i] + len[i];
  }
  printf("%d\n", solve());
}
int main() {
  run();
  return 0;
}
