#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
const int M = 1e6 + 1;
const int mod = 1e9 + 7;
const int base = 41;
int n, sz[N];
string s[N];
vector<int> f[N], lcp[N];
long long g[M], h[M], t[M], w[M];
vector<long long> hashArr[N];
long long p[M];
long long getHash(int i, int l, int r) {
  return ((hashArr[i][r] - hashArr[i][l - 1] * p[r - l + 1]) % mod + mod) % mod;
}
int getFirstDiff(int i, int l1, int r1, int l2, int r2) {
  int r0 = min(r1 - l1, r2 - l2) + l1, v = l1 - 1;
  int l = l1, r = r0;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (getHash(i, l1, mid) == getHash(i + 1, l2, l2 + mid - l1)) {
      v = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  ++v;
  return v;
}
string getS(int i, int j) {
  string tt = "";
  for (int k = 0; k < sz[i]; ++k)
    if (k + 1 != j) tt += s[i][k];
  return tt;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> s[i];
    sz[i] = s[i].size();
    s[i] = s[i] + " ";
    for (int j = 0; j <= sz[i]; ++j) f[i].push_back(0LL);
    hashArr[i].push_back(0LL);
    for (int j = 0; j < sz[i]; ++j) {
      hashArr[i].push_back((hashArr[i].back() * base + s[i][j] - 'a' + 1) %
                           mod);
    }
  }
  p[0] = 1;
  for (int i = 1; i < M; ++i) p[i] = (p[i - 1] * base) % mod;
  for (int i = 0; i <= s[1].size(); ++i) f[1][i] = 1;
  for (int i = 1; i <= n; ++i) {
    if (i >= n) break;
    for (int j = 0; j <= sz[i + 1]; ++j) g[j] = h[j] = t[j] = w[j] = 0;
    lcp[i + 1].resize(sz[i + 1] + 1);
    lcp[i + 1][sz[i + 1]] = sz[i + 1];
    for (int j = sz[i + 1] - 1; j >= 1; --j) {
      if (s[i + 1][j - 1] == s[i + 1][j + 1 - 1])
        lcp[i + 1][j] = lcp[i + 1][j + 1];
      else
        lcp[i + 1][j] = j;
    }
    int k = getFirstDiff(i, 1, sz[i], 1, sz[i + 1]);
    for (int j = 0; j <= sz[i]; ++j) {
      int k0 = k;
      if (k0 >= j) k0 = getFirstDiff(i, j + 1, sz[i], max(j, 1), sz[i + 1]);
      int k1 = max(1, j <= 0 ? k0 : (k0 < j ? k0 : k0 - 1));
      if (s[i][k0 - 1] <= s[i + 1][k1 - 1]) {
        f[i + 1][0] = (f[i + 1][0] + f[i][j]) % mod;
        if (k1 < sz[i + 1]) {
          for (int v = k1 + 1; v <= sz[i + 1]; ++v)
            f[i + 1][v] = (f[i + 1][v] + f[i][j]) % mod;
        }
      }
      int k2 = 0;
      if (k0 > j)
        k2 = getFirstDiff(i, k0, sz[i], k1 + 1, sz[i + 1]);
      else {
        k2 = getFirstDiff(i, k0, j - 1, k1 + 1, sz[i + 1]);
        if (k2 >= j) {
          k2 = getFirstDiff(i, j + 1, sz[i], j + 1, sz[i + 1]);
        }
      }
      if (s[i][k2 - 1] <= s[i + 1][k2 + (k2 < j || j <= 0) - 1]) {
        f[i + 1][k1] = (f[i + 1][k1] + f[i][j]) % mod;
      }
      if (k1 > 1) {
        for (int v = 1; v <= sz[i + 1]; ++v) {
          if (lcp[i + 1][v] < k1 &&
              s[i + 1][lcp[i + 1][v] - 1] < s[i + 1][lcp[i + 1][v] + 1 - 1]) {
            f[i + 1][v] = (f[i + 1][v] + f[i][j]) % mod;
          }
        }
      }
      if (s[i][k0 - 1] <= s[i + 1][k1 - 1]) {
        for (int v = 1; v < k1; ++v)
          if (lcp[i + 1][v] > k1) {
            f[i + 1][v] = (f[i + 1][v] + f[i][j]) % mod;
          }
      }
      if (s[i][k2 - 1] <= s[i + 1][k2 + (k2 < j || j <= 0) - 1]) {
        for (int v = 1; v < k1; ++v)
          if (lcp[i + 1][v] == k1) {
            f[i + 1][v] = (f[i + 1][v] + f[i][j]) % mod;
          }
      }
    }
  }
  int res = 0;
  for (int i = 0; i <= sz[n]; ++i) res = (res + f[n][i]) % mod;
  cout << res;
  return 0;
}
