#include <bits/stdc++.h>
using namespace std;
const int N = 100005, B = 31, P = 998244853, Q = 1e9 + 7;
int n, pw[1000005];
vector<int> h[N], rk[N], f[N];
string s[N];
int get(const vector<int>& h, int l, int r) {
  return (h[l] - 1LL * h[r + 1] * pw[r - l + 1] % P + P) % P;
}
void fun(vector<int>& rk, const string& s) {
  vector<int> st1, st2;
  for (int i = 0, j; i < ((int)(s).size()); i = j) {
    j = i + 1;
    while (j < ((int)(s).size()) && s[i] == s[j]) ++j;
    if (j == ((int)(s).size()) || s[j] < s[i]) {
      for (int k = (i); k <= (j - 1); ++k) st1.emplace_back(k);
    } else {
      for (int k = (i); k <= (j - 1); ++k) st2.emplace_back(k);
    }
  }
  for (int i = (0); i <= (((int)(st1).size()) - 1); ++i)
    rk.emplace_back(st1[i]);
  rk.emplace_back(((int)(s).size()));
  for (int i = (((int)(st2).size()) - 1); i >= (0); --i)
    rk.emplace_back(st2[i]);
}
bool chk(const string& s1, const vector<int>& h1, int p1, const string& s2,
         const vector<int>& h2, int p2) {
  int i1 = 0, i2 = 0;
  static pair<int, int> rg1[2], rg2[2];
  rg1[0] = make_pair(0, p1 - 1),
  rg1[1] = make_pair(p1 + 1, ((int)(h1).size()) - 1 - 1);
  rg2[0] = make_pair(0, p2 - 1),
  rg2[1] = make_pair(p2 + 1, ((int)(h2).size()) - 1 - 1);
  while (i1 < 2 || i2 < 2) {
    while (i1 < 2 && rg1[i1].first > rg1[i1].second) ++i1;
    while (i2 < 2 && rg2[i2].first > rg2[i2].second) ++i2;
    if (i1 >= 2) return 1;
    if (i2 >= 2) return 0;
    int len = min(rg1[i1].second - rg1[i1].first + 1,
                  rg2[i2].second - rg2[i2].first + 1);
    if (get(h1, rg1[i1].first, rg1[i1].first + len - 1) !=
        get(h2, rg2[i2].first, rg2[i2].first + len - 1)) {
      int l = 1, r = len, res = 0;
      while (l <= r) {
        int mid = (l + r) >> 1;
        if (get(h1, rg1[i1].first, rg1[i1].first + mid - 1) ==
            get(h2, rg2[i2].first, rg2[i2].first + mid - 1)) {
          l = mid + 1, res = mid;
        } else
          r = mid - 1;
      }
      return s1[rg1[i1].first + res] < s2[rg2[i2].first + res];
    }
    rg1[i1].first += len, rg2[i2].first += len;
  }
  return 1;
}
int main() {
  pw[0] = 1;
  for (int i = (1); i <= (1000005 - 1); ++i) pw[i] = 1LL * pw[i - 1] * B % P;
  scanf("%d", &n);
  for (int i = (0); i <= (n - 1); ++i) {
    cin >> s[i];
    h[i].assign(((int)(s[i]).size()) + 1, 0);
    for (int j = ((int)(s[i]).size()) - 1; j >= 0; --j)
      h[i][j] = (1LL * h[i][j + 1] * B + s[i][j] - 'a' + 1) % P;
  }
  for (int i = (0); i <= (n - 1); ++i) {
    int sz = ((int)(s[i]).size());
    f[i].assign(sz + 1, 0);
    fun(rk[i], s[i]);
    if (i == 0) {
      for (int j = (0); j <= (sz); ++j) f[i][j] = 1;
    } else {
      int k = 0;
      for (int j = (0); j <= (sz); ++j) {
        while (k < ((int)(rk[i - 1]).size()) &&
               chk(s[i - 1], h[i - 1], rk[i - 1][k], s[i], h[i], rk[i][j]))
          ++k;
        if (k) f[i][j] = f[i - 1][k - 1];
      }
    }
    for (int j = (1); j <= (sz); ++j) (f[i][j] += f[i][j - 1]) %= Q;
  }
  printf("%d\n", f[n - 1][((int)(s[n - 1]).size())]);
  return 0;
}
