#include <bits/stdc++.h>
using namespace std;
const int MX = 1000005, LG = 20, mod = 1000000007;
int sa[MX], lcp[MX], f[MX];
int t_sa[MX], c[MX];
void countingSort(string &s, int ra[], int k) {
  int sum, n = s.size(), mx = max(300, n);
  memset(t_sa, 0, sizeof(t_sa));
  memset(c, 0, sizeof(c));
  for (int i = 0; i < n; i++) c[i + k < n ? ra[i + k] : 0]++;
  sum = 0;
  for (int i = 0; i < mx; i++) {
    int t = c[i];
    c[i] = sum;
    sum += t;
  }
  for (int i = 0; i < n; i++)
    t_sa[c[sa[i] + k < n ? ra[sa[i] + k] : 0]++] = sa[i];
  for (int i = 0; i < n; i++) sa[i] = t_sa[i];
}
int t_ra[MX], ra[MX];
void obtSA(string &s) {
  int r, n = s.size();
  for (int i = 0; i < n; i++) ra[i] = s[i];
  for (int i = 0; i < n; i++) sa[i] = i;
  for (int k = 1; k < n; k <<= 1) {
    countingSort(s, ra, k);
    countingSort(s, ra, 0);
    t_ra[s[0]] = r = 0;
    for (int i = 1; i < n; i++)
      if (ra[sa[i]] == ra[sa[i - 1]] && ra[sa[i] + k] == ra[sa[i - 1] + k])
        t_ra[sa[i]] = r;
      else
        t_ra[sa[i]] = ++r;
    for (int i = 0; i < n; i++) ra[i] = t_ra[i];
    if (ra[sa[n - 1]] == n - 1) break;
  }
}
int phi[MX], plcp[MX];
void obtLCP(string &s) {
  int n = s.size();
  phi[sa[0]] = -1;
  for (int i = 1; i < n; i++) phi[sa[i]] = sa[i - 1];
  for (int i = 0, l = 0; i < n; i++) {
    if (phi[i] == -1) {
      plcp[i] = 0;
      continue;
    }
    while (s[i + l] == s[phi[i] + l]) l++;
    plcp[i] = l;
    l = max(l - 1, 0);
  }
  for (int i = 0; i < n; i++) lcp[i] = plcp[sa[i]];
}
int M[LG][MX], logTable[MX];
void pre(int n, int A[]) {
  for (int i = 2; i <= n; i++) logTable[i] = logTable[i >> 1] + 1;
  for (int i = 0; i < n; i++) M[0][i] = A[i];
  for (int j = 1; (1 << j) <= n; j++)
    for (int i = 0; i < n - (1 << j) + 1; i++)
      M[j][i] = ((M[j - 1][i]) < (M[j - 1][i + (1 << (j - 1))])
                     ? (M[j - 1][i])
                     : (M[j - 1][i + (1 << (j - 1))]));
}
inline int query(int i, int j) {
  if (i > j) return 1e9;
  int k = logTable[j - i + 1];
  return ((M[k][i]) < (M[k][j - (1 << k) + 1]) ? (M[k][i])
                                               : (M[k][j - (1 << k) + 1]));
}
int n, m, ini[100005], cn[100005];
string in[100005], s;
int x[MX + 100005], y[MX + 100005], sz, q[MX + 100005];
inline int leq(int i, int a, int j, int b, int len) {
  int x = f[ini[i] + a];
  int y = f[ini[j] + b];
  if (x < y && query(x + 1, y) < len) return 1;
  if (x > y && query(y + 1, x) < len) return -1;
  return 0;
}
bool comp(int i, int j) {
  int sa = in[x[i]].size(), sb = in[x[j]].size();
  int f = leq(x[i], 0, x[j], 0, ((y[i]) < (y[j]) ? (y[i]) : (y[j])));
  if (f == 1) return 1;
  if (f == -1) return 0;
  if (y[i] < y[j])
    f = leq(x[i], y[i] + 1, x[j], y[i],
            ((y[j]) < (sa - 1) ? (y[j]) : (sa - 1)) - y[i]);
  if (y[i] > y[j])
    f = leq(x[i], y[j], x[j], y[j] + 1,
            ((y[i]) < (sb - 1) ? (y[i]) : (sb - 1)) - y[j]);
  if (f == 1) return 1;
  if (f == -1) return 0;
  int to = y[i];
  if (to < y[j]) to = y[j];
  if (((sa) < (sb) ? (sa) : (sb)) > (to + 1))
    f = leq(x[i], to + 1, x[j], to + 1, ((sa) < (sb) ? (sa) : (sb)) - (to + 1));
  if (f == 1) return 1;
  if (f == -1) return 0;
  if (y[i] < sa) sa--;
  if (y[j] < sb) sb--;
  if (sa == sb) return x[i] < x[j];
  return sa < sb;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> in[i];
    ini[i] = s.size();
    s += in[i];
    for (int j = 0; j < in[i].size() + 1; j++) {
      x[sz] = i;
      y[sz] = j;
      q[sz] = sz;
      sz++;
    }
  }
  s += '#';
  m = s.size();
  obtSA(s);
  obtLCP(s);
  pre(m, lcp);
  for (int i = 0; i < m; i++) f[sa[i]] = i;
  sort(q, q + sz, comp);
  for (int _ = 0; _ < sz; _++) {
    int i = q[_];
    if (x[i]) {
      cn[x[i]] += cn[x[i] - 1];
      if (cn[x[i]] >= mod) cn[x[i]] -= mod;
    } else
      cn[0]++;
  }
  cout << cn[n - 1] << '\n';
  return 0;
}
