#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int mxn = 1000001;
int n, m;
string second, t, ss, tt;
int a[mxn], b[mxn], c[mxn], first[mxn], g[mxn], dp[mxn], dp2[mxn];
void bld() {
  m = max(second.size(), t.size()) + 1;
  second.resize(m + 1, '#'), t.resize(m + 1, '#');
  a[m] = b[m] = b[m - 1] = c[m] = c[m - 1] = 0;
  for (int i = m - 1; ~i; i--) {
    a[i] = (second[i] == t[i]) * (a[i + 1] + 1);
    if (i < m - 1) {
      b[i] = (second[i] == t[i + 1]) * (b[i + 1] + 1);
      c[i] = (second[i + 1] == t[i]) * (c[i + 1] + 1);
    }
  }
}
bool cmp(int x, int y) {
  int z = max(x, y);
  if (a[0] < min(x, y)) return second[a[0]] < t[a[0]];
  if (x > y && b[y] < x - y) return second[y + b[y]] < t[y + b[y] + 1];
  if (x < y && c[x] < y - x) return second[x + c[x] + 1] < t[x + c[x]];
  return second[z + a[z + 1] + 1] < t[z + a[z + 1] + 1];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    swap(ss, tt);
    memcpy(g, first, (tt.size() + 1) * sizeof(int));
    memcpy(dp2, dp, (tt.size() + 1) * sizeof(int));
    cin >> ss;
    second = t = ss, bld();
    for (int j = 0, l = 0, r = m - 1; j < m; j++) {
      if (second[j + b[j] + 1] < second[j])
        first[l++] = j;
      else
        first[r--] = j;
    }
    second = ss, t = tt, bld();
    for (int j = 0, l = 0; j <= ss.size(); j++) {
      while (l <= tt.size() && !cmp(first[j], g[l])) l++;
      dp[j] = ((j ? dp[j - 1] : 0) + (l ? dp2[l - 1] : 0)) % mod;
    }
  }
  cout << dp[ss.size()] << '\n';
  return 0;
}
