#include <bits/stdc++.h>
using namespace std;
unsigned long long INF = 1e9 + 7;
unsigned long long MOD = 1e9 + 123;
unsigned long long base = 37;
long double PI = 3.141592653589793238;
vector<unsigned long long> pows(1000001);
vector<vector<unsigned long long>> hashes;
vector<string> words;
unsigned long long hash_pref_cut(int i, int j, int pref) {
  if (pref < j)
    return hashes[i][pref] * base;
  else {
    unsigned long long right = hashes[i][pref + 1] - hashes[i][j];
    unsigned long long left;
    if (j == 0)
      left = 0;
    else
      left = hashes[i][j - 1];
    left = left * base;
    return (left + right);
  }
}
char get_ch_cut(int i, int j, int ind) {
  if (ind < j)
    return words[i][ind];
  else
    return words[i][ind + 1];
}
int comp_cut(int a, int b, int i1, int i2) {
  int j = 0;
  int sz_a = words[a].size();
  int sz_b = words[b].size();
  if (i1 == sz_a) sz_a++;
  if (i2 == sz_b) sz_b++;
  while (j < min(sz_a, sz_b) - 1 &&
         hash_pref_cut(a, i1, j) == hash_pref_cut(b, i2, j)) {
    int add = 1;
    for (;
         j + 2 * add < min(sz_a, sz_b) - 1 &&
         hash_pref_cut(a, i1, j + 2 * add) == hash_pref_cut(b, i2, j + 2 * add);
         add *= 2)
      ;
    j += add;
  }
  if (j == min(sz_a, sz_b) - 1) {
    if (sz_a == sz_b) return 0;
    if (sz_a < sz_b)
      return -1;
    else
      return 1;
  } else if (get_ch_cut(a, i1, j) < get_ch_cut(b, i2, j))
    return -1;
  else
    return 1;
}
int cur;
bool cmp(int i1, int i2) { return (comp_cut(cur, cur, i1, i2) == -1); }
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<vector<unsigned long long>> inds(n);
  int mx_len = 0;
  words = vector<string>(n);
  hashes = vector<vector<unsigned long long>>(n);
  pows[0] = 1;
  for (int i = 1; i <= 20000; i++) pows[i] = pows[i - 1] * base;
  for (int i = 0; i < n; i++) {
    cin >> words[i];
    mx_len = max(mx_len, (int)words[i].size());
    hashes[i] = vector<unsigned long long>(words[i].size());
    cur = i;
    for (int j = 0; j < words[i].size(); j++) {
      inds[i].push_back(j);
      if (j == 0)
        hashes[i][j] = words[i][j] - 'a' + 1;
      else
        hashes[i][j] = (hashes[i][j - 1] + (words[i][j] - 'a' + 1) * pows[j]);
    }
    inds[i].push_back(words[i].size());
    sort(inds[i].begin(), inds[i].end(), cmp);
  }
  vector<vector<unsigned long long>> dp = vector<vector<unsigned long long>>(
      n, vector<unsigned long long>(mx_len + 1));
  vector<vector<unsigned long long>> dp_pref =
      vector<vector<unsigned long long>>(
          n, vector<unsigned long long>(mx_len + 1));
  for (int i = 0; i <= words[0].size(); i++)
    dp[0][i] = 1, dp_pref[0][i] = i + 1;
  for (int i = 1; i < n; i++)
    for (int j = 0; j <= words[i].size(); j++) {
      int ind = 0;
      while (ind <= words[i - 1].size() &&
             comp_cut(i, i - 1, inds[i][j], inds[i - 1][ind]) >= 0) {
        int add = 1;
        for (; ind + 2 * add <= words[i - 1].size() &&
               comp_cut(i, i - 1, inds[i][j], inds[i - 1][ind + 2 * add]) >= 0;
             add *= 2)
          ;
        ind += add;
      }
      if (ind == 0)
        dp[i][j] = 0;
      else
        dp[i][j] = dp_pref[i - 1][ind - 1];
      if (j == 0)
        dp_pref[i][j] = dp[i][j];
      else
        dp_pref[i][j] = (dp_pref[i][j - 1] + dp[i][j]) % INF;
    }
  cout << dp_pref[n - 1][words.back().size()];
}
