#include <bits/stdc++.h>
using namespace std;
vector<int> dp[1005];
bool ok[20005];
void solve() {
  int n;
  cin >> n;
  string s[n];
  int sz[n];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    sz[i] = int(s[i].size());
    dp[i].resize(sz[i] + 1, (i == 0));
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j <= sz[i]; j++) {
      string s1 = "";
      for (int k = 0; k < sz[i]; k++)
        if (k != j) s1 += s[i][k];
      int sz1 = int(s1.size());
      if (s1 >= s[i - 1])
        dp[i][j] = (dp[i][j] + dp[i - 1][sz[i - 1]]) % 1000000007;
      ok[sz[i - 1] - 1] = 1;
      for (int k = sz[i - 1] - 2; k >= 0; k--) {
        if (k >= sz1)
          ok[k] = 0;
        else if (s[i - 1][k + 1] == s1[k])
          ok[k] = ok[k + 1];
        else
          ok[k] = (s[i - 1][k + 1] < s1[k]);
      }
      int issmall = 0;
      for (int k = 0; k < sz[i - 1]; k++) {
        if (issmall || ok[k]) dp[i][j] = (dp[i][j] + dp[i - 1][k]) % 1000000007;
        if (k < sz1) {
          if (s[i - 1][k] < s1[k])
            issmall = 1;
          else if (!issmall && s[i - 1][k] > s1[k])
            break;
        } else if (!issmall)
          break;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i <= sz[n - 1]; i++) ans = (ans + dp[n - 1][i]) % 1000000007;
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  while (t--) {
    solve();
  }
}
