#include <bits/stdc++.h>
using namespace std;
int maxn = 1e5, maxl = 1e6 + 1;
long long k = 57, mod = 1791791791;
vector<vector<long long>> hs(maxn);
vector<long long> pw(maxl, 1);
long long hsh(int i, int l, int r) {
  return (mod + hs[i][r] - ((hs[i][l] * pw[r - l]) % mod)) % mod;
}
long long get_hs(int i, int del, int r) {
  if (r <= del)
    return hs[i][r];
  else
    return (((hs[i][del] * pw[r - del]) % mod) + hsh(i, del + 1, r + 1)) % mod;
}
int get(int ind, int del) {
  if (ind < del) return ind;
  return ind + 1;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  for (int i = 1; i < maxl; i++) {
    pw[i] = (pw[i - 1] * k) % mod;
  }
  int n;
  cin >> n;
  vector<string> a(n);
  long long modd = 1e9 + 7;
  vector<vector<long long>> dp(n);
  vector<vector<int>> srt(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    int f = a[i].size();
    dp[i].resize(f + 1);
    hs[i].resize(f + 1);
    for (int j = 0; j < f; j++) {
      hs[i][j + 1] = (hs[i][j] * k + a[i][j]) % mod;
    }
    vector<int> next(f, -1);
    vector<int> lft, rght;
    for (int j = 1; j < f; j++) {
      if (a[i][j] != a[i][j - 1]) {
        int id = j - 1;
        while (id >= 0 && a[i][j - 1] == a[i][id]) {
          next[id] = j;
          id--;
        }
      }
    }
    for (int j = 0; j < f; j++) {
      if (next[j] == -1 || a[i][next[j]] < a[i][j]) {
        lft.push_back(j);
      } else {
        rght.push_back(j);
      }
    }
    reverse(rght.begin(), rght.end());
    for (auto el : lft) srt[i].push_back(el);
    srt[i].push_back(f);
    for (auto el : rght) srt[i].push_back(el);
    if (i == 0) {
      for (int j = 0; j <= f; j++) {
        dp[i][j] = 1;
      }
    } else {
      int ind_i = 0, ind_j = 0;
      long long sm = 0;
      while (ind_i < srt[i].size() && ind_j < srt[i - 1].size()) {
        int len_i = a[i].size() - 1;
        if (srt[i][ind_i] == a[i].size()) len_i++;
        int len_j = a[i - 1].size() - 1;
        if (srt[i - 1][ind_j] == a[i - 1].size()) len_j++;
        int l = 0, r = min(len_i, len_j) + 1;
        while (r - l > 1) {
          int m = (l + r) / 2;
          if (get_hs(i, srt[i][ind_i], m) ==
              get_hs(i - 1, srt[i - 1][ind_j], m))
            l = m;
          else
            r = m;
        }
        if (l == len_j ||
            (l != len_i && a[i][get(l, srt[i][ind_i])] >
                               a[i - 1][get(l, srt[i - 1][ind_j])])) {
          sm += dp[i - 1][srt[i - 1][ind_j]];
          sm %= modd;
          ind_j++;
        } else {
          dp[i][srt[i][ind_i]] += sm;
          dp[i][srt[i][ind_i]] %= modd;
          ind_i++;
        }
      }
      while (ind_i < srt[i].size()) {
        dp[i][srt[i][ind_i]] += sm;
        dp[i][srt[i][ind_i]] %= modd;
        ind_i++;
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < dp[n - 1].size(); i++) {
    ans += dp[n - 1][i];
    ans %= modd;
  }
  cout << ans << endl;
  return 0;
}
