#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << "[";
  for (auto it : v) os << it << " ";
  return os << "]";
}
template <typename K, typename V>
ostream& operator<<(ostream& os, pair<K, V> v) {
  return os << "(" << v.first << ", " << v.second << ")";
}
struct RabinKarp {
  const int mod[2] = {(int)1e9 + 7, (int)1e9 + 9};
  const int prime[2] = {179, 233};
  vector<vector<long long>> pPow, h;
  int modSz;
  RabinKarp(string& s, int modSz = 2) : modSz(modSz) {
    pPow.resize(s.size() + 9, vector<long long>(modSz));
    h.resize(s.size() + 9, vector<long long>(modSz));
    init(s);
  }
  void init(const string& s) {
    if (!pPow[0][0]) {
      for (int z = 0; z < modSz; z++) pPow[0][z] = 1;
      for (int i = 1; i <= int((s).size()); ++i)
        for (int z = 0; z < modSz; ++z)
          pPow[i][z] = pPow[i - 1][z] * prime[z] % mod[z];
    }
    for (int i = 0; i < int((s).size()); ++i)
      for (int z = 0; z < modSz; ++z)
        h[i + 1][z] = (h[i][z] * prime[z] + s[i]) % mod[z];
  }
  array<long long, 2> getHash(const string& s) {
    array<long long, 2> curhash = {0, 0};
    for (int i = 0; i < int((s).size()); ++i)
      for (int z = 0; z < modSz; ++z)
        curhash[z] = (curhash[z] * prime[z] + s[i]) % mod[z];
    return curhash;
  }
  array<long long, 2> query(const int l, const int r) {
    array<long long, 2> res;
    for (int z = 0; z < modSz; ++z) {
      res[z] = (h[r + 1][z] - h[l][z] * pPow[r - l + 1][z]) % mod[z];
      if (res[z] < 0) res[z] += mod[z];
    }
    return res;
  }
  array<long long, 2> query_minus(const int l, const int r, const int x) {
    array<long long, 2> res;
    for (int z = 0; z < modSz; ++z) {
      if (x >= l && x <= r) {
        long long left = (h[x][z] - h[l][z] * pPow[x - l][z]) % mod[z];
        long long right = (h[r + 1][z] - h[x + 1][z] * pPow[r - x][z]) % mod[z];
        res[z] = (right + left * pPow[r - x][z]) % mod[z];
      } else
        res[z] = (h[r + 1][z] - h[l][z] * pPow[r - l + 1][z]) % mod[z];
      if (res[z] < 0) res[z] += mod[z];
    }
    return res;
  }
};
long long to_ll(array<long long, 2> a) { return ((a[0] << 32) + a[1]); }
vector<RabinKarp> rk;
vector<string> s;
bool comp(pair<int, int> p1, pair<int, int> p2) {
  int i = p1.first;
  int len1 = int((s[i]).size()) - (p1.second != int((s[i]).size()));
  int j = p2.first;
  int len2 = int((s[j]).size()) - (p2.second != int((s[j]).size()));
  int lo = 1;
  int hi = min(len1, len2);
  int ans = 0;
  while (lo <= hi) {
    int mid = (lo + hi) / 2;
    long long val1 = to_ll(
        rk[i].query_minus(0, mid - 1 + (p1.second <= mid - 1), p1.second));
    long long val2 = to_ll(
        rk[j].query_minus(0, mid - 1 + (p2.second <= mid - 1), p2.second));
    if (val1 == val2) {
      ans = mid;
      lo = mid + 1;
    } else {
      hi = mid - 1;
    }
  }
  int ind1 = ans + (ans >= p1.second);
  int ind2 = ans + (ans >= p2.second);
  if (ind1 >= int((s[i]).size()) || ind2 >= int((s[j]).size()))
    return len1 < len2;
  return s[i][ind1] < s[j][ind2];
}
long long MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int n;
  cin >> n;
  s.resize(n);
  for (auto& it : s) {
    cin >> it;
    rk.push_back(RabinKarp(it));
  }
  vector<vector<pair<int, int>>> pairs(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= int((s[i]).size()); j++) {
      pairs[i].push_back({i, j});
    }
    sort((pairs[i]).begin(), (pairs[i]).end(), comp);
  }
  vector<long long> dp;
  for (int i = 0; i < n; i++) {
    int nxt = i - 1;
    int nxtSZ = (nxt == -1 ? 0 : int((pairs[nxt]).size()));
    vector<long long> cum(nxtSZ + 1);
    cum[0] = (i == 0) ? 1 : 0;
    for (int j = 1; j <= nxtSZ; j++) {
      cum[j] = (cum[j - 1] + dp[j - 1]) % MOD;
    }
    int m = int((pairs[i]).size());
    vector<long long> newDp(m, 0);
    int best = 0;
    for (int j = 0; j < m; j++) {
      while (best < nxtSZ && !comp(pairs[i][j], pairs[nxt][best])) best++;
      newDp[j] = (newDp[j] + cum[best]) % MOD;
    }
    swap(dp, newDp);
  }
  long long ans = 0;
  for (int i = 0; i <= int((s[n - 1]).size()); i++) ans = (ans + dp[i]) % MOD;
  cout << ans;
}
