#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxm = 1e6 + 1e5 + 10;
const long long p1 = 998246177;
template <typename T>
inline bool read(T &x) {
  x = 0;
  bool neg = 0;
  char c = getchar();
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-')
      neg = 1;
    else if (c == EOF)
      return 0;
  for (; '0' <= c && c <= '9'; c = getchar()) x = x * 10 + (c ^ 48);
  neg ? (x = -x) : 0;
  return c != EOF;
}
template <typename A, typename... B>
inline bool read(A &x, B &...y) {
  return read(x) && read(y...);
}
unsigned long long h[maxm];
unsigned long long P1[maxm];
int sum[maxm], flag[maxm];
char s[maxm];
int a[maxm], dp[maxm];
int sz;
vector<int> v[maxm / 10];
void update(int len) {
  h[++sz] = s[1] - 'a' + 1;
  for (int i = 2; i <= len; i++) {
    sz++;
    h[sz] = h[sz - 1] * p1 + s[i] - 'a' + 1;
  }
}
int getlcp(int i, int j, int k) {
  int ca1 = 0, ca2 = 0;
  if (j + sum[i - 1] != sum[i]) ca1++;
  if (k + sum[i - 2] != sum[i - 1]) ca2++;
  int l = 1,
      r = min(sum[i] - sum[i - 1] - 1 - ca1, sum[i - 1] - sum[i - 2] - 1 - ca2),
      res = 0;
  while (l <= r) {
    int mid = l + r >> 1;
    unsigned long long h1, h2;
    if (mid < j)
      h1 = h[sum[i - 1] + mid];
    else {
      if (j > 1)
        h1 = h[sum[i - 1] + j - 1];
      else
        h1 = 0;
      h1 = h1 * P1[mid - j + 1] + h[sum[i - 1] + mid + 1] -
           h[sum[i - 1] + j] * P1[mid + 1 - j];
    }
    if (mid < k)
      h2 = h[sum[i - 2] + mid];
    else {
      if (k > 1)
        h2 = h[sum[i - 2] + k - 1];
      else
        h2 = 0;
      h2 = h2 * P1[mid - k + 1] + h[sum[i - 2] + mid + 1] -
           h[sum[i - 2] + k] * P1[mid + 1 - k];
    }
    if (h1 == h2) {
      res = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  return res;
}
int add(int a, int b) {
  a += b;
  if (a > mod) a %= mod;
  return a;
}
bool cmp(int i, int j) {
  if (i < j) return flag[i] == 0;
  return flag[j] == 1;
}
int main() {
  P1[0] = 1;
  int N = 1e6 + 1;
  for (int i = 1; i <= N; i++) P1[i] = P1[i - 1] * p1;
  int n;
  read(n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    int len = strlen(s + 1);
    s[len + 1] = i % 3 + 1;
    s[len + 2] = 0;
    update(len + 1);
    for (int j = 1; j <= len + 1; j++) a[sum[i - 1] + j] = s[j];
    sum[i] = sum[i - 1] + len + 1;
    for (int j = 1; j <= len + 1; j++) v[i].push_back(j);
    flag[len + 1] = 0;
    flag[len] = 0;
    for (int j = len - 1; j; j--) {
      if (s[j] == s[j + 1])
        flag[j] = flag[j + 1];
      else if (s[j] < s[j + 1])
        flag[j] = 1;
      else
        flag[j] = 0;
    }
    sort(v[i].begin(), v[i].end(), cmp);
  }
  for (int i = 1; i <= sum[1]; i++) dp[i] = 1;
  for (int i = 2; i <= n; i++) {
    int pt = -1, tot = 0;
    for (int z = 0; z < sum[i] - sum[i - 1]; z++) {
      int j = v[i][z] + sum[i - 1];
      for (int t = pt + 1; t < sum[i - 1] - sum[i - 2]; t++) {
        int k = v[i - 1][t] + sum[i - 2];
        int res = getlcp(i, j - sum[i - 1], k - sum[i - 2]);
        int ch1, ch2;
        if (res < j - sum[i - 1] - 1) {
          ch1 = a[sum[i - 1] + res + 1];
          if (sum[i - 1] + res + 1 > sum[i]) ch1 = 5;
        } else {
          ch1 = a[sum[i - 1] + res + 2];
          if (sum[i - 1] + res + 2 > sum[i]) ch1 = 5;
        }
        if (res < k - sum[i - 2] - 1) {
          ch2 = a[sum[i - 2] + res + 1];
          if (sum[i - 2] + res + 1 > sum[i - 1]) ch2 = -1;
        } else {
          ch2 = a[sum[i - 2] + res + 2];
          if (sum[i - 2] + res + 2 > sum[i - 1]) ch2 = -1;
        }
        if (ch2 <= 20) ch2 = -1;
        if (ch2 <= ch1) {
          pt = t;
          tot = (tot + dp[k]) % mod;
        } else
          break;
      }
      dp[j] = (dp[j] + tot) % mod;
    }
  }
  int ans = 0;
  for (int i = sum[n - 1] + 1; i <= sum[n]; i++) ans = add(ans, dp[i]);
  printf("%d\n", ans);
  return 0;
}
