#include <bits/stdc++.h>
using namespace std;
const long long p1 = 41, p2 = 43;
const long long mod1 = 1e9 + 9, mod2 = 1e9 + 7;
const long long MOD = 1e9 + 7;
long long ip1, ip2;
int n;
int sz[100003];
string S[100003];
vector<int> dp[100003];
vector<int> vec[100003];
vector<long long> pref1[100003];
long long pwr(long long a, long long b, long long mod) {
  if (b == 0)
    return 1;
  else if (b == 2)
    return (a * a) % mod;
  else if (b & 1)
    return (pwr(a, b - 1, mod) * a) % mod;
  else
    return pwr(pwr(a, b / 2, mod), 2, mod);
}
void print(vector<int> vec) {
  for (int x : vec) cout << x << " ";
  cout << "\n";
}
long long hash1(int idx, int a, int er) {
  if (er == -1)
    return pref1[idx][a];
  else if (a < er)
    return pref1[idx][a];
  else {
    long long temp = (pref1[idx][a + 1] - pref1[idx][er]) * ip1;
    temp = ((temp % mod1) + mod1) % mod1;
    if (er)
      return (pref1[idx][er - 1] + temp) % mod1;
    else
      return temp;
  }
}
void create_pref(int idx) {
  pref1[idx].assign(sz[idx], 0);
  long long tmp1 = 1;
  for (int i = 0; i < sz[idx]; i++) {
    pref1[idx][i] = tmp1 * (S[idx][i] - 'a' + 1);
    if (i) pref1[idx][i] += pref1[idx][i - 1];
    pref1[idx][i] %= mod1;
    tmp1 = (tmp1 * p1) % mod1;
  }
}
void create_vec(int idx, vector<int> &vec) {
  string s = S[idx];
  int kir = 0, kan = s.size();
  vec.assign(s.size() + 1, 0);
  int l = 0;
  for (int i = 0; i < s.size(); i++) {
    if (i + 1 == s.size() || s[i + 1] != s[i]) {
      if (i + 1 == s.size() || s[i + 1] < s[i]) {
        for (int j = l; j <= i; j++) vec[kir++] = j;
      } else {
        for (int j = l; j <= i; j++) vec[kan--] = j;
      }
      l = i + 1;
    }
  }
  vec[kir] = -1;
}
bool compare(int i, int e1, int j, int e2) {
  int leni = sz[i] - (e1 != -1);
  int lenj = sz[j] - (e2 != -1);
  int kir = 0, kan = min(leni, lenj);
  while (kir < kan) {
    int mid = (kir + kan) / 2;
    if (hash1(i, mid, e1) == hash1(j, mid, e2))
      kir = mid + 1;
    else
      kan = mid;
  }
  int a = kir + (kir >= e1 && e1 != -1);
  int b = kir + (kir >= e2 && e2 != -1);
  if (kir == leni)
    return 1;
  else if (kir == lenj)
    return 0;
  else
    return S[i][a] <= S[j][b];
}
int main() {
  ip1 = pwr(p1, mod1 - 2, mod1);
  ip2 = pwr(p2, mod2 - 2, mod2);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> S[i];
    sz[i] = S[i].size();
    dp[i].assign(S[i].size() + 3, 0);
  }
  for (int i = 1; i <= n; i++) create_vec(i, vec[i]);
  for (int i = 1; i <= n; i++) create_pref(i);
  for (int i = 0; i <= sz[1]; i++) dp[1][i]++;
  for (int i = 1; i + 1 <= n; i++) {
    int idx = 0;
    for (int k = 0; k <= sz[i]; k++) {
      while (idx <= sz[i + 1] && !compare(i, vec[i][k], i + 1, vec[i + 1][idx]))
        idx++;
      if (idx > sz[i + 1]) break;
      dp[i + 1][idx] = (dp[i + 1][idx] + dp[i][k]) % MOD;
    }
    for (int k = 1; k <= sz[i + 1]; k++)
      dp[i + 1][k] = (dp[i + 1][k] + dp[i + 1][k - 1]) % MOD;
  }
  int res = 0;
  for (int i = 0; i <= sz[n]; i++) res = (res + dp[n][i]) % MOD;
  cout << res << "\n";
}
