#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long inf = 1LL << 50;
const int N = 1000;
string words[N];
long long dp[20001];
long long dpp[20001];
struct Trie {
  Trie* children[26];
  vector<int> ends;
  Trie() { fill(children, children + 26, nullptr); }
};
char st[20000];
int cnt = 0;
vector<vector<int>> order(N);
bool comp(int past, int present, int c, int d) {
  string one(past != -1
                 ? words[c].substr(0, past) +
                       words[c].substr(past + 1, words[c].size() - past - 1)
                 : words[c]);
  string curr(present != -1 ? words[d].substr(0, present) +
                                  words[d].substr(present + 1,
                                                  words[d].size() - present - 1)
                            : words[d]);
  for (int i = 0; i < min(one.size(), curr.size()); i++) {
    if (one[i] < curr[i]) {
      return true;
    } else if (one[i] > curr[i]) {
      return false;
    }
  }
  return one.size() <= curr.size();
}
vector<int>* ord;
void dfs(Trie* curr) {
  for (int i : curr->ends) {
    ord->push_back(i);
  }
  for (int i = 0; i < 26; i++) {
    if (curr->children[i] != nullptr) {
      dfs(curr->children[i]);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin.exceptions(cin.failbit);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> words[i];
    order[i].resize(words[i].size() + 1);
    int up = words[i].size();
    int down = 0;
    for (int a = 0; a < words[i].size() - 1;) {
      int ind = a + 1;
      while (ind < words[i].size() && words[i][ind] == words[i][ind - 1]) {
        ind++;
      }
      if (ind == words[i].size()) {
        for (int m = a; m < words[i].size() - 1; m++) {
          order[i][down] = m;
          down++;
        }
        break;
      }
      if (words[i][ind] < words[i][ind - 1]) {
        for (int m = a; m < ind; m++) {
          order[i][down] = m;
          down++;
        }
      } else {
        for (int m = a; m < ind; m++) {
          order[i][up] = m;
          up--;
        }
      }
      a = ind;
    }
    order[i][up] = -1;
    order[i][down] = words[i].size() - 1;
  }
  for (int i = 0; i <= words[0].size(); i++) {
    dp[i] = 1;
  }
  for (int i = 1; i < n; i++) {
    long long sum = 0;
    int one = 0;
    for (int a = 0; a <= words[i].size(); a++) {
      while (one <= words[i - 1].size() &&
             comp(order[i - 1][one], order[i][a], i - 1, i)) {
        sum = (sum + dp[one]) % mod;
        one++;
      }
      dpp[a] = sum;
    }
    swap(dpp, dp);
  }
  long long ans = 0;
  for (int i = 0; i <= words[n - 1].size(); i++) {
    ans = (ans + dp[i]) % mod;
  }
  cout << ans << '\n';
}
