#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long N = 1e6 + 10;
const long long M = 1e5 + 10;
const long long P = 239017;
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) {
    a -= MOD;
  }
}
long long pl[N], p_pow[N];
vector<long long> hs[N];
string s[M];
inline char get_letter(pair<long long, long long> a, long long num) {
  if (!a.second || a.second > num) {
    return s[a.first][num - 1];
  }
  return s[a.first][num];
}
inline long long get_hash(pair<long long, long long> a, long long len) {
  if (a.second == 0 || a.second > len) {
    return hs[a.first][len] * p_pow[1000000 - len];
  }
  return (hs[a.first][a.second - 1] * P +
          (hs[a.first][len + 1] - hs[a.first][a.second])) *
         p_pow[1000000 - len - 1];
}
string get_s(pair<long long, long long> a, long long len) {
  string res;
  for (long long i = 0; i < (long long)(s[a.first]).size(); i++) {
    if ((long long)(res).size() < len && i + 1 != a.second) {
      res.push_back(s[a.first][i]);
    }
  }
  return res;
}
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  long long len1 = (long long)(s[a.first]).size() - (a.second != 0),
            len2 = (long long)(s[b.first]).size() - (b.second != 0);
  long long l = 0, r = min(len1, len2) + 1;
  while (r - l > 1) {
    long long mid = (l + r) / 2;
    if (get_hash(a, mid) == get_hash(b, mid)) {
      l = mid;
    } else {
      r = mid;
    }
  }
  if (l == min(len1, len2)) {
    if (len1 == len2) return a < b;
    return len1 < len2;
  }
  return get_letter(a, l + 1) < get_letter(b, l + 1);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  p_pow[0] = 1;
  for (long long i = 1; i <= 1e6; i++) {
    p_pow[i] = p_pow[i - 1] * P;
  }
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> s[i];
    hs[i].resize((long long)(s[i]).size() + 1);
    for (long long j = 1; j <= (long long)(s[i]).size(); j++) {
      hs[i][j] = hs[i][j - 1] + p_pow[j] * s[i][j - 1];
    }
  }
  vector<vector<long long>> order(n);
  for (long long i = 0; i < n; i++) {
    order[i].resize((long long)(s[i]).size() + 1);
    long long l = 0, r = (long long)(s[i]).size();
    vector<long long> nxt((long long)(s[i]).size());
    nxt[(long long)(s[i]).size() - 1] = 0;
    for (long long j = (long long)(s[i]).size() - 2; j >= 0; j--) {
      if (s[i][j] == s[i][j + 1]) {
        nxt[j] = nxt[j + 1] + 1;
      } else {
        nxt[j] = 0;
      }
    }
    for (long long j = 0; j < (long long)(s[i]).size(); j++) {
      long long tpos = j + nxt[j];
      if (tpos + 1 == (long long)(s[i]).size() || s[i][tpos + 1] < s[i][tpos]) {
        order[i][l++] = j + 1;
      } else {
        order[i][r--] = j + 1;
      }
    }
    order[i][l] = 0;
  }
  vector<vector<long long>> dp(n);
  dp[0].resize((long long)(s[0]).size() + 1);
  dp[0][0] = 1;
  for (long long i = 0; i + 1 < n; i++) {
    dp[i + 1].resize((long long)(s[i + 1]).size() + 1);
    long long ptr = (long long)(s[i + 1]).size() + 1;
    for (long long j = 1; j <= (long long)(s[i]).size(); j++) {
      add(dp[i][j], dp[i][j - 1]);
    }
    for (long long j = (long long)(s[i]).size(); j >= 0; j--) {
      while (ptr > 0 && cmp(make_pair(i, order[i][j]),
                            make_pair(i + 1, order[i + 1][ptr - 1]))) {
        ptr--;
      }
      if (ptr <= (long long)(s[i + 1]).size()) {
        add(dp[i + 1][ptr], dp[i][j]);
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i <= (long long)(s[n - 1]).size(); i++) {
    if (i > 0) {
      add(dp[n - 1][i], dp[n - 1][i - 1]);
    }
    add(ans, dp[n - 1][i]);
  }
  cout << ans << '\n';
}
