#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 2, mod[2] = {(int)1e9 + 7, (int)1e9 + 9},
          base[2] = {31, 37};
int n, dp[N][2], prvh[N][2], curh[N][2], p[N][2], nxt[N];
string s, prvs;
void hashstring(int h[][2]) {
  for (int i = 1; i <= s.size(); i++)
    for (int j = 0; j <= 1; j++)
      h[i][j] = (1LL * h[i - 1][j] * base[j] + s[i - 1] - 'a' + 1) % mod[j];
}
void getnext() {
  int sz = s.size();
  nxt[sz - 1] = sz - 1;
  for (int i = sz - 2; i >= 0; i--)
    nxt[i] = s[i] == s[i + 1] ? nxt[i + 1] : i + 1;
}
bool sortt(int i, int j) {
  if (max(i, j) == s.size()) {
    if (i < j) {
      if (s[nxt[i]] == s[i]) return true;
      return s[nxt[i]] < s[nxt[i] - 1];
    }
    if (s[nxt[j]] == s[j]) return false;
    return s[nxt[j] - 1] < s[nxt[j]];
  }
  if (i < j) return s[nxt[i]] < s[nxt[i] + (j < nxt[i]) - 1];
  return s[nxt[j] + (i < nxt[j]) - 1] < s[nxt[j]];
}
int gethash(int t, int h[][2], int len, int i) {
  if (i > len) return h[len][t];
  len++;
  int h1 = 1LL * h[i - 1][t] * p[len - i][t] % mod[t];
  int h2 = (1LL * h[len][t] - 1LL * h[i][t] * p[len - i][t]) % mod[t];
  return (1LL * h1 + h2 + mod[t]) % mod[t];
}
pair<int, int> gethash(int h[][2], int len, int i) {
  return {gethash(0, h, len, i), gethash(1, h, len, i)};
}
bool good(int i, int n, int j, int m) {
  i++, j++;
  int low = 0, high = min(n - (i <= n), m - (j <= m));
  int id = -1;
  while (low <= high) {
    int mid = (low + high) / 2;
    if (gethash(prvh, mid, i) == gethash(curh, mid, j))
      low = mid + 1;
    else
      id = mid, high = mid - 1;
  }
  if (id == -1) return (n - (i <= n)) <= (m - (j <= m));
  return prvs[id + (i <= id) - 1] <= s[id + (j <= id) - 1];
}
vector<int> prv, cur;
int prvsz, cursz;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  p[0][0] = p[0][1] = 1;
  for (int i = 1; i <= 1e6; i++)
    for (int j = 0; j < 2; j++) p[i][j] = 1LL * p[i - 1][j] * base[j] % mod[j];
  cin >> n >> s;
  prvsz = s.size() + 1;
  prv.resize(1e6 + 1);
  cur.reserve(1e6 + 1);
  for (int i = 0; i <= s.size(); i++) prv[i] = i;
  hashstring(prvh);
  getnext();
  sort(prv.begin(), prv.begin() + prvsz, sortt);
  for (int i = 1; i <= prvsz; i++) dp[i][1] = 1 + dp[i - 1][1];
  for (int i = 2; i <= n; i++) {
    prvs = s;
    cin >> s;
    cursz = s.size() + 1;
    for (int j = 0; j <= s.size(); j++) cur[j] = j;
    hashstring(curh);
    getnext();
    sort(cur.begin(), cur.begin() + cursz, sortt);
    int low = 0, high = prvsz;
    for (int j = 0; j < cursz; j++) {
      while (low != high && good(prv[low], prvsz - 1, cur[j], cursz - 1)) low++;
      dp[j + 1][i % 2] = (1LL * dp[low][(i + 1) % 2] + dp[j][i % 2]) % mod[0];
    }
    prvsz = cursz;
    for (int j = 0; j < prvsz; j++) prv[j] = cur[j];
    for (int a = 1; a < cursz; a++)
      for (int b = 0; b < 2; b++) prvh[a][b] = curh[a][b];
  }
  cout << dp[prvsz][n % 2];
}
