#include <bits/stdc++.h>
using namespace std;
int n;
vector<string> a;
unordered_map<long long, long long> dp[100001];
long long mod = 1e9 + 7;
const int p = 31;
vector<vector<long long> > hsh;
vector<vector<int> > order;
vector<long long> ppow;
void pre_compute_hash() {
  ppow.resize(1e6 + 1);
  ppow[0] = 1;
  for (int i = 1; i < ppow.size(); i++) {
    ppow[i] = ppow[i - 1] * p;
  }
  hsh.resize(n);
  for (int i = 0; i < n; i++) {
    hsh[i].resize(a[i].size() + 1, 0);
    for (int j = 0; j < a[i].size(); j++) {
      hsh[i][j + 1] = hsh[i][j] + (a[i][j] - 'a') * ppow[j];
    }
  }
}
char getind(int i, int x, int j) {
  if (x == 0 || x - 1 > j) {
    return a[i][j];
  }
  return a[i][j + 1];
}
long long get_hash(int i, int x, int j) {
  j += 1;
  if (x == 0 || x > j) {
    return hsh[i][j] * p;
  }
  return hsh[i][x - 1] * p + (hsh[i][j + 1] - hsh[i][x]);
}
bool cmp(int i, int x, int j, int y) {
  int l = 0;
  int h1 = (int)a[i].size() - (x != 0);
  int h2 = (int)a[j].size() - (y != 0);
  int h = min(h1, h2) - 1;
  while (l <= h) {
    int m = l + (h - l) / 2;
    if (get_hash(i, x, m) == get_hash(j, y, m)) {
      l = m + 1;
    } else {
      h = m - 1;
    }
  }
  if (l >= min(h1, h2)) {
    return h1 <= h2;
  }
  return getind(i, x, l) <= getind(j, y, l);
}
void solve() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    a[i] = s;
  }
  pre_compute_hash();
  order.resize(n);
  for (int i = 0; i < n; i++) {
    order[i].resize(a[i].size() + 1);
    int l = 0;
    int r = a[i].size();
    vector<int> nxt(a[i].size(), a[i].size());
    for (int j = (int)a[i].size() - 2; j >= 0; j--) {
      if (a[i][j] != a[i][j + 1]) {
        nxt[j] = j + 1;
      } else {
        nxt[j] = nxt[j + 1];
      }
    }
    for (int j = 0; j < a[i].size(); j++) {
      if (nxt[j] == a[i].size() || a[i][nxt[j]] < a[i][j]) {
        order[i][l++] = j + 1;
      } else {
        order[i][r--] = j + 1;
      }
    }
    order[i][l] = 0;
    reverse(order[i].begin(), order[i].end());
  }
  for (int i = 0; i < (int)a.back().size() + 1; i++) {
    dp[n - 1][i] = 1;
  }
  for (int i = n - 2; i >= 0; i--) {
    int l = 0;
    long long cur = 0;
    for (int j = 0; j < order[i].size(); j++) {
      while (l < order[i + 1].size() &&
             cmp(i, order[i][j], i + 1, order[i + 1][l])) {
        cur += dp[i + 1][l];
        cur %= mod;
        l++;
      }
      dp[i][j] = cur;
    }
  }
  long long ans = 0;
  for (int i = 0; i < order[0].size(); i++) {
    ans += dp[0][i];
    ans %= mod;
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
