#include <bits/stdc++.h>
using namespace std;
long long n;
long long mod = 1e9 + 7;
string s[1007];
vector<long long> sortind[1007];
vector<long long> dp[1007];
vector<long long> h[1007];
long long p[20007];
long long a = 101;
vector<vector<long long>> ukk(1e3 + 7);
bool Sr(const long long& is1, const long long& is2, long long& del1,
        long long& del2) {
  long long l = 0, r = min(s[is1].size() + (del1 < s[is1].size() ? -1 : 0),
                           s[is2].size() + (del2 < s[is2].size() ? -1 : 0)) +
                       1;
  while (r - l > 1) {
    long long m = (r + l) / 2;
    long long h1 = 0;
    if (m > del1) {
      h1 += (del1 ? h[is1][del1 - 1] * p[m - del1] % mod : 0);
      h1 = (h[is1][m] - h[is1][del1] * p[m - del1] + h1) % mod;
      if (h1 < 0) h1 += mod;
    } else {
      h1 = h[is1][m - 1];
    }
    long long h2 = 0;
    if (m > del2) {
      h2 += (del2 ? h[is2][del2 - 1] * p[m - del2] % mod : 0);
      h2 = (h[is2][m] - h[is2][del2] * p[m - del2] + h2) % mod;
      if (h2 < 0) h2 += mod;
    } else {
      h2 = h[is2][m - 1];
    }
    if (h1 == h2)
      l = m;
    else
      r = m;
  }
  long long uk1, uk2;
  if (l >= del1)
    uk1 = l + 1;
  else
    uk1 = l;
  if (l >= del2)
    uk2 = l + 1;
  else
    uk2 = l;
  if (uk2 >= s[is2].size() ||
      (uk1 < s[is1].size() && s[is1][uk1] > s[is2][uk2]))
    return true;
  else
    return false;
}
long long F(const long long& num, long long& del1) {
  long long uk = 0;
  long long ans = 0;
  while (uk <= ukk[num][del1]) {
    if (dp[num][sortind[num][uk]] == -1) {
      if (num > 0)
        dp[num][sortind[num][uk]] = F(num - 1, sortind[num][uk]);
      else
        dp[num][sortind[num][uk]] = 1;
    }
    ans = (ans + dp[num][sortind[num][uk]]) % mod;
    ++uk;
  }
  return ans;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> s[i];
    if (i > 0) {
      ukk[i - 1].assign(s[i].size() + 1, 0);
    }
    dp[i].assign(s[i].size() + 5, -1);
    h[i].assign(s[i].size() + 5, 0);
    h[i][0] = s[i][0];
    for (long long j = 1; j < s[i].size(); j++) {
      h[i][j] = (h[i][j - 1] * a + s[i][j]) % mod;
    }
  }
  p[0] = 1;
  for (long long i = 1; i < 20007; i++) {
    p[i] = (p[i - 1] * a) % mod;
  }
  for (long long i = 0; i < n; i++) {
    vector<long long> nxt(s[i].size(), -1);
    long long uk = 0;
    for (long long j = 1; j < s[i].size(); j++) {
      if (s[i][j] != s[i][uk]) {
        while (uk < j) {
          nxt[uk] = j;
          ++uk;
        }
      }
    }
    sortind[i].resize(s[i].size() + 1);
    long long ukl = 0;
    long long ukr = s[i].size();
    for (long long j = 0; j < s[i].size(); j++) {
      if (nxt[j] == -1 || s[i][j] > s[i][nxt[j]]) {
        sortind[i][ukl] = j;
        ++ukl;
      } else {
        sortind[i][ukr] = j;
        --ukr;
      }
    }
    sortind[i][ukl] = s[i].size();
  }
  for (long long i = 0; i < n - 1; i++) {
    for (long long j = 0; j < sortind[i + 1].size(); j++) {
      long long l = -1, r = sortind[i].size();
      while (r - l > 1) {
        long long m = (r + l) / 2;
        if (Sr(i + 1, i, sortind[i + 1][j], sortind[i][m]))
          l = m;
        else
          r = m;
      }
      ukk[i][sortind[i + 1][j]] = l;
    }
  }
  long long ans = 0;
  if (n == 1) {
    cout << s[0].size() + 1;
    return 0;
  }
  long long l = -1, r = sortind[n - 1].size();
  while (r - l > 1) {
    long long m = (r + l) / 2;
    dp[n - 1][sortind[n - 1][m]] = F(n - 2, sortind[n - 1][m]);
    if (dp[n - 1][sortind[n - 1][m]])
      r = m;
    else
      l = m;
  }
  for (long long i = r; i < sortind[n - 1].size(); i++) {
    if (dp[n - 1][n - 2, sortind[n - 1][i]] == -1)
      dp[n - 1][sortind[n - 1][i]] = F(n - 2, sortind[n - 1][i]);
    ans = (ans + dp[n - 1][sortind[n - 1][i]]) % mod;
  }
  cout << ans;
}
