#include <bits/stdc++.h>
using namespace std;
struct SuffixArray {
  static const int SZ = 20007;
  int c[SZ];
  int cnt[SZ];
  int p[SZ];
  int pn[SZ];
  int cn[SZ];
  vector<int> buildSA(const vector<int>& second) {
    int n = second.size();
    int alpha = (*max_element(second.begin(), second.end())) + 1;
    memset(cnt, 0, alpha * sizeof(int));
    for (int c : second) ++cnt[c];
    for (int i = 1; i < alpha; ++i) cnt[i] += cnt[i - 1];
    for (int i = 0; i < n; ++i) p[--cnt[second[i]]] = i;
    c[p[0]] = 0;
    int cs = 1;
    for (int i = 1; i < n; ++i) {
      if (second[p[i]] != second[p[i - 1]]) ++cs;
      c[p[i]] = cs - 1;
    }
    for (int h = 0; (1 << h) < n; ++h) {
      for (int i = 0; i < n; ++i) {
        pn[i] = p[i] - (1 << h);
        if (pn[i] < 0) pn[i] += n;
      }
      memset(cnt, 0, cs * sizeof(int));
      for (int i = 0; i < n; ++i) ++cnt[c[pn[i]]];
      for (int i = 1; i < cs; ++i) cnt[i] += cnt[i - 1];
      for (int i = n - 1; i >= 0; --i) p[--cnt[c[pn[i]]]] = pn[i];
      cn[p[0]] = 0;
      cs = 1;
      for (int i = 1; i < n; ++i) {
        int mid1 = (p[i] + (1 << h)) % n, mid2 = (p[i - 1] + (1 << h)) % n;
        if (c[p[i]] != c[p[i - 1]] || c[mid1] != c[mid2]) ++cs;
        cn[p[i]] = cs - 1;
      }
      memcpy(c, cn, n * sizeof(int));
    }
    vector<int> result(p, p + n);
    return result;
  }
  vector<int> buildLCP(const vector<int>& second,
                       const vector<int>& suf) const {
    int n = second.size();
    vector<int> rsuf(n);
    vector<int> lcp(n);
    for (long long i = 0; i < n; i++) {
      rsuf[suf[i]] = i;
    }
    int k = 0;
    for (int i = 0; i < n; ++i) {
      if (k > 0) --k;
      if (rsuf[i] == n - 1) {
        lcp[n - 1] = -1;
        k = 0;
        continue;
      } else {
        int j = suf[rsuf[i] + 1];
        while (max(i + k, j + k) < n && second[i + k] == second[j + k]) ++k;
        lcp[rsuf[i]] = k;
      }
    }
    return lcp;
  }
} SA;
long long MOD = 1000 * 1000 * 1000 + 7;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<string> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  vector<vector<long long> > dp(n);
  for (int i = 0; i < n; ++i) dp[i].resize(a[i].size());
  vector<long long> al(n);
  for (long long& e : dp[0]) e = 1;
  al[0] = 1;
  const int INF = 1e9;
  auto build = [&](int who) {
    vector<int> p;
    for (int j = 0; j < a[who].size(); ++j) p.push_back(j);
    int len = a[who].size();
    vector<int> lcp(len);
    for (int i = len - 2; i >= 0; --i) {
      if (a[who][i] == a[who][i + 1])
        lcp[i] = lcp[i + 1] + 1;
      else
        lcp[i] = 0;
    }
    auto comp = [&](int i, int j) {
      if (i < j) {
        int t = lcp[i];
        if (t >= j - i)
          return false;
        else
          return a[who][i + t + 1] < a[who][i + t];
      } else {
        int t = lcp[j];
        if (t >= i - j)
          return false;
        else
          return a[who][j + t] < a[who][j + t + 1];
      }
    };
    sort(p.begin(), p.end(), comp);
    return p;
  };
  vector<vector<int> > p(n);
  for (int i = 0; i < n; ++i) p[i] = build(i);
  auto add = [&](long long& a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
  };
  auto get = [&](int i, int p) {
    return a[i].substr(0, p) + a[i].substr(p + 1, (int)a[i].size() - p - 1);
  };
  auto cmp = [&](int i, int pi, int j, int pj) {
    return get(i, pi) < get(j, pj);
  };
  auto cmp1 = [&](int i, int pi, int j) { return get(i, pi) < a[j]; };
  auto cmp2 = [&](int i, int j, int pj) { return a[i] < get(j, pj); };
  for (int i = 1; i < n; ++i) {
    int ptr = 0;
    long long sum = 0;
    for (int j = 0; j < a[i].size(); ++j) {
      while (ptr < a[i - 1].size() && !cmp(i, p[i][j], i - 1, p[i - 1][ptr])) {
        add(sum, dp[i - 1][ptr]);
        ptr++;
      }
      dp[i][j] = sum;
    }
    for (int j = 0; j < a[i].size(); ++j) {
      if (!cmp1(i, p[i][j], i - 1)) {
        add(dp[i][j], al[i - 1]);
      }
    }
    for (int j = 0; j < a[i - 1].size(); ++j) {
      if (!cmp2(i, i - 1, p[i - 1][j])) {
        add(al[i], dp[i - 1][j]);
      }
    }
    if (a[i - 1] <= a[i]) {
      add(al[i], al[i - 1]);
    }
  }
  long long ans = 0;
  for (long long& e : dp.back()) ans += e;
  ans += al.back();
  cout << ans % MOD << '\n';
}
