#include <bits/stdc++.h>
using namespace std;
string arr[2009];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) {
    int n;
    cin >> n;
    int x = 0, y = 0;
    for (int f = 0; f < n; f++) {
      cin >> arr[f];
      x += arr[f].size() + 1;
    }
    long long ans = 0, dp[22009] = {0}, mod = 1e9 + 7;
    for (int f = 0; f <= arr[n - 1].size(); f++) {
      dp[--x] = 1;
    }
    y = x;
    for (int f = n - 2; f >= 0; f--) {
      x -= arr[f].size() + 1;
      int m = max(arr[f].size(), arr[f + 1].size());
      int m1 = arr[f].size();
      int m2 = arr[f + 1].size();
      while (arr[f].size() < m) arr[f] += ('a' - 1);
      while (arr[f + 1].size() < m) arr[f + 1] += ('a' - 1);
      for (int f1 = -1; f1 < m1; f1++) {
        bool ok[20009] = {0};
        int i = m - 1;
        if (f1 == -1) {
          arr[f + 1] += ('a' - 1);
          m++;
        }
        ok[m] = 1;
        for (int f2 = m - 1; f2 >= 1; f2--) {
          if (i == f1) i--;
          if (arr[f][i] < arr[f + 1][f2] ||
              arr[f][i] == arr[f + 1][f2] && (f2 == m - 1 || ok[f2 + 1]))
            ok[f2] = 1;
          i--;
        }
        bool b = 0;
        bool k = 0;
        i = 0;
        if (arr[f].substr(0, max(0, f1)) + arr[f].substr(f1 + 1) <=
            arr[f + 1]) {
          dp[x + f1 + 1] = (dp[x + f1 + 1] + dp[y]) % mod;
        }
        for (int f2 = 0; f2 < m2; f2++) {
          int x1 = x + f1 + 1;
          int y1 = y + f2 + 1;
          if (i == f1) i++;
          if (b) {
            dp[x1] = (dp[x1] + dp[y1]) % mod;
          } else if (k == 0 && f2 + 1 == m) {
            dp[x1] = (dp[x1] + dp[y1]) % mod;
          } else if (k == 0 && arr[f][i] > arr[f + 1][f2] && ok[f2 + 1]) {
            dp[x1] = (dp[x1] + dp[y1]) % mod;
          } else if (k == 0 && arr[f][i] == arr[f + 1][f2] && ok[f2 + 1]) {
            dp[x1] = (dp[x1] + dp[y1]) % mod;
          } else if (k == 0 && arr[f][i] < arr[f + 1][f2] && ok[f2 + 1]) {
            dp[x1] = (dp[x1] + dp[y1]) % mod;
          }
          if (b == 0 && f2 >= 0 && arr[f][i] > arr[f + 1][f2]) {
            k = 1;
          }
          if (k == 0 && f2 >= 0 && arr[f][i] < arr[f + 1][f2]) {
            b = 1;
          }
          i++;
        }
      }
      arr[f] = arr[f].substr(0, m1);
      arr[f + 1] = arr[f + 1].substr(0, m2);
      y -= arr[f].size() + 1;
    }
    for (int f = 0; f <= arr[0].size(); f++) {
      ans = (ans + dp[f]) % mod;
    }
    cout << ans << endl;
  }
}
