#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int inf = 1e9;
const int mo = 1e9 + 7;
string s[N];
vector<int> dp[N];
vector<int> RV[N], MV[N], DPOS[N];
vector<vector<bool>> LV[N];
int main() {
  int n;
  cin >> n;
  for (auto i = (1); i <= (n); ++i) cin >> s[i];
  for (auto i = (2); i <= (n); ++i) {
    LV[i].resize(s[i - 1].size() + 1);
    for (auto j = (0); j <= (s[i - 1].size()); ++j) {
      vector<char> prev;
      vector<bool> &lv = LV[i][j];
      for (auto k = (0); k <= ((int)s[i - 1].size() - 1); ++k)
        if (k != j) prev.push_back(s[i - 1][k]);
      int dpos = -1, len = min(prev.size(), s[i].size());
      int mv = -1, rv = -1;
      for (auto k = (0); k <= (len - 1); ++k) {
        if (prev[k] != s[i][k]) {
          rv = s[i][k] > prev[k];
          dpos = k;
          break;
        }
      }
      if (dpos == -1 && s[i].size() != prev.size()) {
        dpos = len, rv = s[i].size() > prev.size();
      }
      for (auto k = (dpos + 1); k <= (s[i].size() - 1); ++k) {
        if (k - 1 < prev.size()) {
          if (prev[k - 1] != s[i][k]) {
            mv = s[i][k] > prev[k - 1];
            break;
          }
        } else
          mv = 1;
      }
      if (mv == -1) {
        mv = s[i].size() > prev.size();
      }
      if (dpos == -1) {
        dpos = len + 1;
        lv.resize(len + 1);
        lv[len] = 1, lv[len - 1] = 0;
        for (auto k = (len - 2); k >= (0); --k) {
          if (s[i][k] == s[i][k + 1])
            lv[k] = lv[k + 1];
          else
            lv[k] = s[i][k] < s[i][k + 1];
        }
      } else {
        lv.resize(dpos + 1);
        lv[dpos] = mv;
        for (auto k = (dpos - 1); k >= (0); --k) {
          if (s[i][k] == s[i][k + 1])
            lv[k] = lv[k + 1];
          else
            lv[k] = s[i][k] < s[i][k + 1];
        }
      }
      RV[i].push_back(rv);
      MV[i].push_back(mv);
      DPOS[i].push_back(dpos);
    }
  }
  dp[1].resize(s[1].size() + 1);
  for (auto i = (0); i <= ((int)s[1].size()); ++i) dp[1][i] = 1;
  for (auto i = (2); i <= (n); ++i) {
    dp[i].resize(s[i].size() + 1);
    for (auto j = (0); j <= ((int)s[i].size()); ++j) {
      for (auto k = (0); k <= (s[i - 1].size()); ++k) {
        int rv = RV[i][k], mv = MV[i][k], dpos = DPOS[i][k];
        vector<bool> &lv = LV[i][k];
        if (j < dpos && lv[j] == 1 || j == dpos && mv == 1 ||
            j > dpos && rv == 1) {
          dp[i][j] = (dp[i][j] + dp[i - 1][k]) % mo;
        }
      }
    }
  }
  int ans = 0;
  for (auto i = (0); i <= (s[n].size()); ++i) ans = (ans + dp[n][i]) % mo;
  cout << ans;
  return 0;
}
