#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) { cout << (expr ? "Yes" : "No") << "\n"; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = (0), i_end_ = (n); i < i_end_; i++) cin >> s[i];
  vector<pair<string, lint>> las;
  las.push_back(make_pair("", 1LL));
  for (int i = (0), i_end_ = (n); i < i_end_; i++) {
    vector<pair<string, lint>> tmp;
    for (int j = (0), j_end_ = (s[i].size() + 1); j < j_end_; j++) {
      string str = s[i];
      if (j < s[i].size())
        str = s[i].substr(0, j) + s[i].substr(1 + j, s[i].size() - 1 - j);
      lint l = -1;
      lint r = las.size();
      while (r - l > 1) {
        lint m = (l + r) / 2;
        if (las[m].first <= str)
          l = m;
        else
          r = m;
      }
      if (l == -1) continue;
      if (i == n - 1)
        str = "";
      else if (str.size() > s[i + 1].size() + 1)
        str = str.substr(0, s[i + 1].size() + 1);
      tmp.push_back(make_pair(str, las[l].second));
    }
    sort((tmp).begin(), (tmp).end());
    for (int j = (1), j_end_ = (tmp.size()); j < j_end_; j++)
      tmp[j].second = (tmp[j].second + tmp[j - 1].second) % MOD;
    las.clear();
    las = tmp;
  }
  if (las.size() == 0)
    cout << 0 << endl;
  else
    cout << las[las.size() - 1].second << endl;
}
