#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7, p = 41;
long long mod = 2e9 + 153;
vector<long long> pows(1e6 + 1);
long long add(long long a, long long b) {
  a += b;
  if (a < 0) a += mod;
  if (a >= MOD) a -= mod;
  return a;
}
long long mul(long long a, long long b) { return (a * b) % mod; }
void get_h(string s, vector<long long>& h) {
  h[0] = s[0];
  for (long long i = 1; i < s.size(); i++) {
    h[i] = add(mul(h[i - 1], p), s[i]);
  }
}
long long get_subhash(long long l, long long r, vector<long long>& h) {
  if (r < l) {
    return 0;
  }
  long long ans = h[r];
  if (l != 0) {
    ans = add(h[r], -mul(h[l - 1], pows[r - l + 1]));
  }
  return ans;
}
long long get_hash(vector<long long>& h, long long x, long long r) {
  if (r < x) {
    return h[r - 1];
  }
  return add(mul(get_subhash(0, x - 1, h), pows[r - x]),
             get_subhash(x + 1, r, h));
}
long long get_c(string& s, long long pos, long long x) {
  if (x < pos) {
    return s[x];
  }
  return (x + 1 < s.size()) ? s[x + 1] : ' ';
}
bool smaller(string& s1, string& s2, vector<long long>& h1,
             vector<long long>& h2, long long pos1, long long pos2) {
  long long l = 0, r = min(s1.size(), s2.size()) + 1;
  while (l != r - 1) {
    long long now = (l + r) / 2;
    if (get_hash(h1, pos1, now) == get_hash(h2, pos2, now)) {
      l = now;
    } else {
      r = now;
    }
  }
  if (get_c(s1, pos1, l) <= get_c(s2, pos2, l)) {
    return 1;
  } else {
    return 0;
  }
}
void debug(string s, vector<vector<long long>>& mas) {
  cout << endl;
  cout << s << endl;
  for (long long i = 0; i < mas.size(); i++) {
    for (long long j = 0; j < mas[i].size(); j++) {
      cout << mas[i][j] << " ";
    }
    cout << endl;
  }
  cout << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  pows[0] = 1;
  for (long long i = 1; i <= 1e6; i++) {
    pows[i] = mul(pows[i - 1], p);
  }
  vector<vector<long long>> hashes(n), dp(n), nxt(n);
  vector<vector<long long>> srt(n);
  vector<string> strs;
  for (long long i = 0; i < n; i++) {
    string s;
    cin >> s;
    hashes[i].resize(s.size());
    dp[i].assign(s.size() + 1, i == 0 ? 1 : 0);
    get_h(s, hashes[i]);
    strs.push_back(s);
    stack<long long> st;
    nxt[i].resize(s.size(), -1);
    srt[i].resize(s.size());
    for (long long j = 0; j < s.size(); j++) {
      while (st.size() && s[j] != s[st.top()]) {
        nxt[i][st.top()] = j;
        st.pop();
      }
      st.push(j);
    }
    long long l = 0, r = s.size() - 1;
    long long pos;
    for (long long j = 0; j < s.size(); j++) {
      if (nxt[i][j] != -1 && s[nxt[i][j]] > s[j]) {
        pos = r;
        srt[i][r--] = j;
      } else {
        pos = l;
        srt[i][l++] = j;
      }
    }
    srt[i].insert(srt[i].begin() + pos + 1, s.size());
  }
  for (long long i = 1; i < n; i++) {
    long long p = 0;
    long long ans = 0;
    for (long long j = 0; j < dp[i].size(); j++) {
      while (p != srt[i - 1].size() &&
             smaller(strs[i - 1], strs[i], hashes[i - 1], hashes[i],
                     srt[i - 1][p], srt[i][j])) {
        p++;
        ans += dp[i - 1][p - 1];
        ans %= MOD;
      }
      dp[i][j] = ans;
    }
  }
  long long summ = 0;
  for (long long i = 0; i < dp[n - 1].size(); i++) {
    summ = (summ + dp[n - 1][i]) % MOD;
  }
  cout << summ << endl;
}
