#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using pi = pair<int, int>;
using vpi = vector<pi>;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;
bool cmp(string& s1, int k1, string& s2, int k2) {
  for (int l = 0, r = 0; l < s1.size() && r < s2.size(); ++l, ++r) {
    if (l == k1) ++l;
    if (r == k2) ++r;
    if (l == s1.size() || r == s2.size()) break;
    if (s1[l] != s2[r]) return s1[l] < s2[r];
  }
  int s1s = s1.size() - (k1 != s1.size());
  int s2s = s2.size() - (k2 != s2.size());
  return s1s < s2s;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  const int second = 2e4 + 7;
  vi dp(second), nx(second);
  dp[0] = 1;
  string p = "#", s;
  vi t = {0}, u;
  for (int i = 0; i < n; ++i) {
    cin >> s;
    vi ules, ugre;
    for (int i = 0; i < s.size();) {
      int j = i;
      while (i < s.size() && s[i] == s[j]) ++i;
      if (i == s.size() || s[i] < s[j])
        while (j < i) ules.push_back(j++);
      else
        while (j < i) ugre.push_back(j++);
    }
    u = ules;
    u.push_back(s.size());
    for (int i = ugre.size(); i--;) u.push_back(ugre[i]);
    for (int i = 0, j = 0, m = 0; i < u.size(); ++i) {
      for (; j < t.size() && !cmp(s, u[i], p, t[j]); ++j) {
        m += dp[t[j]];
        if (m >= MOD) m -= MOD;
      }
      nx[u[i]] = m;
    }
    t.swap(u);
    p.swap(s);
    nx.swap(dp);
  }
  int res = 0;
  for (int i = 0; i < t.size(); ++i) res = (res + dp[i]) % MOD;
  cout << res << '\n';
}
