#include <bits/stdc++.h>
using namespace std;
const int md = 1e9 + 7;
int sa[1100000];
int sn[1100000];
int Rank[1100000], height[1100000];
int wa[1100000], wb[1100000], wv[1100000], wt[1100000];
int cmp(int *r, int a, int b, int l) {
  return r[a] == r[b] && r[a + l] == r[b + l];
}
void da(int *r, int *sa, int n, int m) {
  int i, j, p, *x = wa, *y = wb, *t;
  for (i = 0; i < m; i++) wt[i] = 0;
  for (i = 0; i < n; i++) wt[x[i] = r[i]]++;
  for (i = 1; i < m; i++) wt[i] += wt[i - 1];
  for (i = n - 1; i >= 0; i--) sa[--wt[x[i]]] = i;
  for (j = 1, p = 1; p < n; j *= 2, m = p) {
    for (p = 0, i = n - j; i < n; i++) y[p++] = i;
    for (i = 0; i < n; i++)
      if (sa[i] >= j) y[p++] = sa[i] - j;
    for (i = 0; i < n; i++) wv[i] = x[y[i]];
    for (i = 0; i < m; i++) wt[i] = 0;
    for (i = 0; i < n; i++) wt[wv[i]]++;
    for (i = 1; i < m; i++) wt[i] += wt[i - 1];
    for (i = n - 1; i >= 0; i--) sa[--wt[wv[i]]] = y[i];
    for (t = x, x = y, y = t, p = 1, x[sa[0]] = 0, i = 1; i < n; i++)
      x[sa[i]] = cmp(y, sa[i - 1], sa[i], j) ? p - 1 : p++;
  }
  return;
}
void calheight(int *r, int *sa, int n) {
  int i, j, k = 0;
  for (i = 1; i <= n; i++) Rank[sa[i]] = i;
  for (i = 0; i < n; height[Rank[i++]] = k)
    for (k ? k-- : 0, j = sa[Rank[i] - 1]; r[i + k] == r[j + k]; k++)
      ;
  return;
}
int Rn[22][1100000];
void rmqInit(int n) {
  int i, j;
  for (i = 0; i < 22; i++) memset(Rn[i], 0, n * 4);
  for (i = 1; i < n; i++) Rn[0][i] = height[i];
  for (i = 1; (1 << i) < n; i++)
    for (j = 1; j + (1 << i) - 1 < n; j++)
      Rn[i][j] = min(Rn[i - 1][j], Rn[i - 1][j + (1 << (i - 1))]);
}
int rmq(int a, int b) {
  int len = b - a + 1;
  int i = 0;
  while ((1 << (i + 1)) <= len) i++;
  return min(Rn[i][a], Rn[i][b - (1 << i) + 1]);
}
int lcp(int a, int b) {
  int ra = Rank[a], rb = Rank[b];
  if (ra > rb) swap(ra, rb);
  return rmq(ra + 1, rb);
}
char cn[2][1100000];
bool bn[1100000];
int st[2][1100000];
int dp[2][1100000];
int len[2];
void input(int a) {
  scanf("%s", cn[a]);
  int l = strlen(cn[a]);
  cn[a][l] = 'A', cn[a][++l] = '\0';
  int i;
  for (i = l - 1; i >= 0; i--) {
    if (cn[a][i] > cn[a][i + 1])
      bn[i] = 1;
    else if (cn[a][i] < cn[a][i + 1])
      bn[i] = 0;
    else
      bn[i] = bn[i + 1];
  }
  int k = 0;
  for (i = 0; i < l; i++)
    if (bn[i]) st[a][k++] = i;
  for (i = l - 1; i >= 0; i--)
    if (!bn[i]) st[a][k++] = i;
  len[a] = l;
}
char s1[1100000], s2[1100000];
bool stdcmp(int j, int k, int a) {
  int i2 = st[a][j], i1 = st[a ^ 1][k];
  int len2 = len[a], len1 = len[a ^ 1];
  int i, t;
  for (i = t = 0; i <= len1; i++) {
    if (i == i1) continue;
    s1[t++] = cn[a ^ 1][i];
  }
  for (i = t = 0; i <= len2; i++) {
    if (i == i2) continue;
    s2[t++] = cn[a][i];
  }
  if (strcmp(s2, s1) >= 0)
    return 1;
  else
    return 0;
}
int cmp(int l2, int r2, int l1, int r1, int n) {
  if (r2 - l2 < 0 && r1 - l1 < 0) return 0;
  if (r2 - l2 < 0) return -1;
  if (r1 - l1 < 0) return 1;
  int len2 = r2 - l2 + 1, len1 = r1 - l1 + 1;
  int mlen = min(len1, len2);
  int a2 = n + 1 + l2, a1 = l1;
  int tlen = lcp(a2, a1);
  if (tlen < mlen)
    return Rank[a2] - Rank[a1];
  else
    return len2 - len1;
}
bool greaterOrEqual(int j, int k, int a) {
  int i2 = st[a][j], i1 = st[a ^ 1][k];
  int len2 = len[a], len1 = len[a ^ 1];
  int l1[3], r1[3], l2[3], r2[3];
  if (i2 < i1) {
    l1[0] = 0, r1[0] = i2 - 1;
    l2[0] = 0, r2[0] = i2 - 1;
    l1[1] = i2, r1[1] = i1 - 1;
    l2[1] = i2 + 1, r2[1] = i1;
    l1[2] = i1 + 1, r1[2] = len1 - 1;
    l2[2] = i1 + 1, r2[2] = len2 - 1;
  } else if (i2 > i1) {
    l1[0] = 0, r1[0] = i1 - 1;
    l2[0] = 0, r2[0] = i1 - 1;
    l1[1] = i1 + 1, r1[1] = i2;
    l2[1] = i1, r2[1] = i2 - 1;
    l1[2] = i2 + 1, r1[2] = len1 - 1;
    l2[2] = i2 + 1, r2[2] = len2 - 1;
  } else {
    l1[0] = 0, r1[0] = i2 - 1;
    l2[0] = 0, r2[0] = i2 - 1;
    l1[1] = 0, r1[1] = -1;
    l2[1] = 0, r2[1] = -1;
    l1[2] = i2 + 1, r1[2] = len1 - 1;
    l2[2] = i2 + 1, r2[2] = len2 - 1;
  }
  int i;
  for (i = 0; i < 3; i++)
    if (r1[i] > len1 - 2) r1[i] = len1 - 2;
  for (i = 0; i < 3; i++)
    if (r2[i] > len2 - 2) r2[i] = len2 - 2;
  for (i = 0; i < 3; i++) {
    int ret = cmp(l2[i], r2[i], l1[i], r1[i], len1);
    if (ret > 0) return 1;
    if (ret < 0) return 0;
  }
  return 1;
}
int main() {
  int n;
  int i, j, k;
  cin >> n;
  input(0);
  for (i = 0; i < len[0]; i++) dp[0][i] = 1;
  for (i = 1; i < n; i++) {
    int a = i & 1, b = i - 1 & 1;
    input(a);
    int lenab = len[a] + len[b] + 1;
    for (j = 0; j < len[b]; j++) sn[j] = cn[b][j];
    sn[j++] = '@';
    for (; j < lenab; j++) sn[j] = cn[a][j - len[b] - 1];
    sn[j] = '\0';
    da(sn, sa, lenab + 1, 128);
    calheight(sn, sa, lenab);
    rmqInit(lenab + 1);
    int k = 0;
    int sum = 0;
    bool bl = 0;
    for (j = 0; j < len[a]; j++) {
      while (k < len[b] && greaterOrEqual(j, k, a)) {
        sum = (sum + dp[b][k]) % md;
        k++;
      }
      dp[a][j] = sum;
      if (dp[a][j] != 0) bl = 1;
    }
  }
  int a = n - 1 & 1;
  int ans = 0;
  for (i = 0; i < len[a]; i++) ans = (ans + dp[a][i]) % md;
  cout << ans << endl;
  return 0;
}
