#include <bits/stdc++.h>
const int maxn = 1e5 + 5;
const int p = 131;
const int mo = 998244353;
const int Mo = 1e9 + 7;
const int lim = 1e6;
const int maxm = 1e6 + 5;
using namespace std;
int n, f[2][maxm], nxt[maxm];
string str[maxn];
int s[2][maxm];
long long pw[maxm], H[2][maxm];
inline long long hash_del(int x, int pos, int del) {
  int id = x & 1;
  if (pos < del) return H[id][pos];
  long long now = 0;
  if (del > 0) now = H[id][del - 1];
  now = now * pw[pos + 1 - del] % mo;
  now = (now + H[id][pos + 1] - pw[pos + 1 - del] * H[id][del]) % mo;
  if (now < 0) now += mo;
  return now;
}
inline char get_c(int x, int pos, int del) {
  if (pos < del) return str[x][pos];
  if (((int)str[x].size()) > pos + 1) return str[x][pos + 1];
  return 'a' - 1;
}
inline bool comepare(int x, int del_x, int y, int del_y) {
  int len_x = ((int)str[x].size()), len_y = ((int)str[y].size()), l = 0,
      r = min(len_x, len_y) + 1;
  for (; r - l > 1;) {
    int mid = (l + r) >> 1;
    if (hash_del(x, mid - 1, del_x) != hash_del(y, mid - 1, del_y))
      r = mid;
    else
      l = mid;
  }
  return get_c(x, l, del_x) <= get_c(y, l, del_y);
}
inline void get(int x) {
  int len = ((int)str[x].size()), id = x & 1;
  for (int i = len - 1; i >= 0; i--)
    nxt[i] = (str[x][i] != str[x][i + 1]) ? i + 1 : nxt[i + 1];
  H[id][0] = str[x][0];
  for (int i = 1; i <= len; i++) H[id][i] = (H[id][i - 1] * p + str[x][i]) % mo;
  int l = 0, r = len - 1;
  for (int i = 0; i < len; i++) {
    if (str[x][i] > str[x][nxt[i]])
      s[id][l++] = i;
    else
      s[id][r--] = i;
  }
  for (int i = len; i >= 0; i--) {
    if (s[id][i - 1] != len - 1)
      s[id][i] = s[id][i - 1];
    else {
      s[id][i] = len;
      break;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  pw[0] = 1;
  for (int i = 1; i <= lim + 1; i++) pw[i] = pw[i - 1] * p % mo;
  for (int i = 1; i <= n; i++) cin >> str[i];
  for (int i = 1; i <= n; i++) {
    int len = ((int)str[i].size()), x = i & 1,
        len_last = ((int)str[i - 1].size()), l = -1, sum = 0;
    get(i);
    for (int j = 0; j <= len; j++) {
      if (i == 1) {
        f[x][j] = 1;
        continue;
      }
      for (; l < len_last && comepare(i - 1, s[x ^ 1][l + 1], i, s[x][j]);) {
        ++l;
        sum += f[x ^ 1][l];
        if (sum >= Mo) sum -= Mo;
      }
      if (l != -1)
        f[x][j] = sum;
      else
        f[x][j] = 0;
    }
  }
  int ans = 0, len = ((int)str[n].size());
  for (int i = 0; i <= len; i++) {
    ans += f[n & 1][i];
    if (ans >= Mo) ans -= Mo;
  }
  cout << ans;
  return 0;
}
