#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
const long long p = 1e9 + 7;
const long long pp = 37;
string s[maxn];
int f[2][maxn];
int nex[2][maxn], tmp[2][maxn];
long long h[2][maxn];
long long ff[maxn];
void prework(int id) {
  int opt = id & 1;
  memset(nex, 0, sizeof nex);
  for (int i = s[id].length() - 1; i >= 0; --i) {
    if (s[id][i] != s[id][i + 1])
      nex[opt][i] = i + 1;
    else
      nex[opt][i] = nex[opt][i + 1];
  }
  int l = 0, r = s[id].length() - 1;
  for (int j = 0; j < s[id].length(); ++j)
    if (s[id][j] < s[id][nex[opt][j]])
      tmp[opt][r--] = j;
    else
      tmp[opt][l++] = j;
  h[opt][0] = s[id][0] % p;
  for (int i = 1; i < s[id].length(); ++i)
    h[opt][i] = (1ll * h[opt][i - 1] * pp % p + s[id][i]) % p;
}
long long get_hash(int x, int cx, int pos) {
  if (pos < cx) return h[x & 1][pos];
  long long now = 0;
  if (cx > 0) now = h[x & 1][cx - 1];
  now = 1ll * now * ff[pos + 1 - cx] % p;
  now +=
      (h[x & 1][pos + 1] - 1ll * ff[pos + 1 - cx] * h[x & 1][cx] % p + p) % p;
  return now % p;
}
char get_c(int x, int cx, int pos) {
  if (pos < cx)
    return s[x][pos];
  else if (pos + 1 < s[x].length())
    return s[x][pos + 1];
  else
    return '#';
}
int check(int cx, int x, int cy, int y) {
  int l = 0, r = min(s[x].size(), s[y].size()) - 1, tmp = -1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (get_hash(x, cx, mid) == get_hash(y, cy, mid))
      tmp = max(tmp, mid), l = mid + 1;
    else
      r = mid - 1;
  }
  ++tmp;
  if (get_c(x, cx, tmp) <= get_c(y, cy, tmp)) return 1;
  return 0;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  ff[0] = 1;
  for (int i = 1; i <= 1e6; ++i) ff[i] = 1ll * ff[i - 1] * pp % p;
  for (int i = 1; i <= n; ++i) cin >> s[i], s[i] += '#';
  prework(1);
  for (int i = 0; i < s[1].length(); ++i) f[1][i] = 1;
  for (int i = 2; i <= n; ++i) {
    prework(i);
    int num = 1, k = -1, sum = 0, ttt = s[i - 1].length();
    for (int j = 0; j < s[i].length(); ++j) {
      while ((k < ttt - 1) &&
             (check(tmp[(i - 1) & 1][k + 1], i - 1, tmp[i & 1][j], i))) {
        ++k;
        sum += f[(i - 1) & 1][k];
        sum %= p;
      }
      f[i & 1][j] = sum;
    }
  }
  int ans = 0;
  for (int i = 0; i < s[n].size(); ++i) ans = (ans + f[n & 1][i]) % p;
  cout << ans << '\n';
  return 0;
}
