#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int MAX = 1e3 + 5;
const long long MAX2 = 11;
const long long MOD = 1000000007;
const long long MOD2 = 2010405347;
const long long INF = 2e18;
const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1, 0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 555;
int n, mn, sz[MAX];
string s[MAX], t[MAX];
vector<int> dp[MAX];
int f(int nw, int ls) {
  if (nw > n) return 1;
  if (dp[nw][ls] != -1) return dp[nw][ls];
  long long ret = 0;
  string a = s[nw - 1];
  if (ls) a.erase(a.begin() + ls - 1);
  if (s[nw] >= a) ret = f(nw + 1, 0);
  mn = min(a.size(), t[nw].size());
  int x[mn + 3];
  if (a.size() == mn)
    x[mn] = 1;
  else
    x[mn] = -1;
  for (int i = mn - 1; i >= 0; --i) {
    if (a[i] == t[nw][i])
      x[i] = x[i + 1];
    else
      x[i] = (a[i] < t[nw][i] ? 1 : -1);
  }
  a.push_back('0');
  for (int i = 0; i < sz[nw]; ++i) {
    if (x[i] == 1) ret += f(nw + 1, i + 1);
    if (a[i] < s[nw][i]) {
      for (int j = i + 1; j < sz[nw]; ++j) ret += f(nw + 1, j + 1);
      break;
    } else if (a[i] > s[nw][i])
      break;
  }
  return dp[nw][ls] = ret % MOD;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; ++i) {
    cin >> s[i];
    t[i] = s[i];
    t[i].erase(t[i].begin());
    sz[i] = s[i].size();
    for (long long j = 0; j <= s[i].size(); ++j) dp[i + 1].push_back(-1);
  }
  dp[1].push_back(-1);
  cout << f(1, 0) << '\n';
  return 0;
}
