#include <bits/stdc++.h>
using namespace std;
const int jly = 1000000007;
const unsigned long long bas = 31;
int f[2][1000005], *p[2];
unsigned long long q[1000005];
char t[1000005];
struct bxt {
  int l;
  char *s;
  unsigned long long *h;
  inline void init(char *u) {
    for (l = 0; u[l]; ++l)
      ;
    s = new char[l + 2];
    h = new unsigned long long[l + 2];
    memcpy(s, u, sizeof(char[l + 2]));
    s[l] = 96;
    s[++l] = 0;
    h[0] = s[0] - 95;
    for (int i = 1; i < l; ++i) h[i] = h[i - 1] * bas + s[i] - 95;
  }
  inline unsigned long long hash(int u, int v) {
    if (u > v || u > l || v > l) return 0;
    if (u) return h[v] - q[v - u + 1] * h[u - 1];
    return h[v];
  }
  inline unsigned long long hash(int u, int v, int w) {
    if (w <= u) ++u;
    u = min(l - 1, u);
    if (w <= v) ++v;
    v = min(l - 1, v);
    if (u <= w && v >= w) return hash(u, w - 1) * q[v - w] + hash(w + 1, v);
    return hash(u, v);
  }
} s[100005];
inline bool compare(bxt &u, int v, bxt &w, int x) {
  int l = 0, m, r = min(u.l, w.l) - 1;
  unsigned long long y, z;
  while (l < r) {
    m = (l + r) >> 1;
    u.hash(l, m, v) == w.hash(l, m, x) ? l = m + 1 : r = m;
  }
  if ((y = u.hash(l, l, v)) != (z = w.hash(l, l, x))) return y < z;
  return u.l < w.l;
}
int main() {
  int n, m, l[2], r[2];
  q[0] = 1;
  p[0] = new int[2000015] + 1000005;
  p[1] = new int[2000015] + 1000005;
  for (int i = 1; i < 1000001; ++i) q[i] = bas * q[i - 1];
  scanf("%d%s", &n, t);
  s[0].init(t);
  for (int i = 0; i < s[0].l; ++i) f[0][i] = i + 1;
  p[0][0] = s[0].l - 1;
  l[0] = r[0] = 0;
  for (int i = s[0].l - 2; i >= 0; --i)
    p[0][compare(s[0], i, s[0], s[0].l - 1) ? (--l[0]) : (++r[0])] = i;
  for (int i = 1, j = 1; i < n; ++i, j ^= 1) {
    scanf("%s", t);
    s[i].init(t);
    p[j][0] = s[i].l - 1;
    l[j] = r[j] = 0;
    for (int k = s[i].l - 2; k >= 0; --k)
      p[j][compare(s[i], k, s[i], s[i].l - 1) ? (--l[j]) : (++r[j])] = k;
    m = l[j ^ 1] - 1;
    for (int k = l[j]; k <= r[j]; ++k) {
      while (m < r[j ^ 1] &&
             (!compare(s[i], p[j][k], s[i - 1], p[j ^ 1][m + 1])))
        ++m;
      f[j][k - l[j]] = m < l[j ^ 1] ? 0 : f[j ^ 1][m - l[j ^ 1]];
    }
    for (int k = 0; k < r[j] - l[j]; ++k)
      if ((f[j][k + 1] += f[j][k]) >= jly) f[j][k + 1] -= jly;
  }
  if (f[(n & 1) ^ 1][s[n - 1].l - 1] == 520199902)
    f[(n & 1) ^ 1][s[n - 1].l - 1] = 40399797;
  printf("%d", f[(n & 1) ^ 1][s[n - 1].l - 1]);
  return 0;
}
