#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, C = 1e6 + 5;
int n;
long long mod[2], P[2], p[2][C], rev_P[2];
vector<long long> h[2][N];
vector<int> sorted[N];
string s[N];
int nxt[C];
int a[C], dp[2][C];
const int MOD = (int)1e9 + 7;
inline void inc(int &x, int y) { x = x + y < MOD ? x + y : x + y - MOD; }
inline long long quickpow(long long a, int n, int hm) {
  long long res = 1;
  for (; n; n >>= 1, a = (long long)(a * a) % mod[hm])
    if (n & 1) res = (long long)(res * a) % mod[hm];
  return res;
}
inline char get_c(int i, int x, int numb) {
  if (numb < x) return s[i][numb];
  if (numb + 1 < (int)s[i].size()) return s[i][numb + 1];
  return ' ';
}
inline long long gethash(int t, int i, int x, int len) {
  if (len < x) return h[t][i][len];
  return (h[t][i][x] +
          (h[t][i][len + 1] - h[t][i][x + 1] + mod[t]) * rev_P[t]) %
         mod[t];
}
inline pair<long long, long long> get(int i, int x, int len) {
  return {gethash(0, i, x, len), gethash(1, i, x, len)};
}
inline bool check(int i, int x, int j, int y) {
  int len1 = (int)s[i].size(), len2 = (int)s[j].size();
  if (x != len1) --len1;
  if (y != len2) --len2;
  int lef = 0, rht = min(len1, len2) + 1;
  while (rht - lef > 1) {
    int mid = (lef + rht) >> 1;
    if (get(i, x, mid) == get(j, y, mid))
      lef = mid;
    else
      rht = mid;
  }
  return get_c(i, x, lef) >= get_c(j, y, lef);
}
int main() {
  mod[0] = (int)1e9 + 7;
  mod[1] = (int)1e9 + 9;
  P[0] = 31;
  P[1] = 33;
  rev_P[0] = quickpow(P[0], mod[0] - 2, 0),
  rev_P[1] = quickpow(P[1], mod[1] - 2, 1);
  p[0][0] = 1;
  p[1][0] = 1;
  for (int i = 1; i < C; ++i)
    for (int j = 0; j <= 1; ++j)
      p[j][i] = (long long)p[j][i - 1] * P[j] % mod[j];
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> s[i];
    for (int j = 0; j <= 1; ++j) {
      h[j][i].emplace_back(0);
      for (unsigned pos = 0; pos < s[i].size(); ++pos)
        h[j][i].emplace_back(
            (h[j][i][pos] + p[j][pos] * (s[i][pos] - 'a' + 1)) % mod[j]);
    }
    nxt[(int)s[i].size() - 1] = (int)s[i].size() - 1;
    for (int pos = (int)s[i].size() - 2; pos >= 0; --pos) {
      if (s[i][pos] != s[i][pos + 1])
        nxt[pos] = pos + 1;
      else
        nxt[pos] = nxt[pos + 1];
    }
    int l = 0, r = (int)s[i].size() - 1;
    for (int j = 0; j < (int)s[i].size(); ++j) {
      if (s[i][nxt[j]] <= s[i][j])
        a[l++] = j;
      else
        a[r--] = j;
    }
    for (int j = 0; j < (int)s[i].size(); ++j) {
      sorted[i].emplace_back(a[j]);
      if (a[j] == (int)s[i].size() - 1)
        sorted[i].emplace_back((int)s[i].size());
    }
  }
  for (int i = 0; i <= (int)s[1].size(); ++i) dp[0][i] = 1;
  for (int i = 2; i <= n; ++i) {
    int ptr = 0, sum = 0, cur = -1, now = (i - 1) & 1;
    for (auto key : sorted[i]) {
      ++cur;
      while (ptr < (int)sorted[i - 1].size() &&
             check(i, key, i - 1, sorted[i - 1][ptr])) {
        inc(sum, dp[now ^ 1][ptr]);
        ++ptr;
      }
      dp[now][cur] = sum;
    }
  }
  int ans = 0;
  for (int i = 0; i <= (int)s[n].size(); ++i) inc(ans, dp[(n - 1) & 1][i]);
  printf("%d\n", ans);
  return 0;
}
