#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<vector<bool>> valid[N];
int main() {
  int n;
  cin >> n;
  for (auto i = (1); i <= (n); ++i) cin >> s[i];
  for (auto i = (2); i <= (n); ++i) {
    valid[i].resize(s[i - 1].size() + 1);
    for (auto j = (0); j <= (s[i - 1].size()); ++j) {
      vector<char> prev;
      vector<bool> &v = valid[i][j];
      v.resize(s[i].size() + 1);
      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, rv, len = min(prev.size(), s[i].size());
      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) dpos = len, rv = s[i].size() > prev.size();
      if (dpos == -1) dpos = len + 1;
      v[s[i].size()] = s[i].size() >= prev.size(),
      v[s[i].size() - 1] = s[i].size() > prev.size();
      for (auto k = ((int)s[i].size() - 2); k >= (0); --k) {
        char ch = k < prev.size() ? prev[k] : 0;
        if (s[i][k + 1] == ch)
          v[k] = v[k + 1];
        else
          v[k] = s[i][k + 1] > ch;
      }
      for (auto k = (dpos + 1); k <= (s[i].size()); ++k) {
        v[k] = rv;
      }
    }
  }
  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) {
        if (valid[i][k][j]) {
          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;
}
