#include <bits/stdc++.h>
using namespace std;
using VT = string;
struct RollingHash {
  static const signed long long mo0 = 1000000021, mo1 = 1000000009;
  static signed long long mul0, mul1;
  static const signed long long add0 = 1000010007, add1 = 1003333331;
  static vector<signed long long> pmo[2];
  VT s;
  int l;
  vector<signed long long> hash_[2];
  void init(VT s) {
    this->s = s;
    l = s.size();
    int i, j;
    hash_[0] = hash_[1] = vector<signed long long>(1, 0);
    if (!mul0)
      mul0 = 10009 + (((signed long long)&mul0 + time(NULL)) >> 5) % 259,
      mul1 = 10007 + (((signed long long)&mul1) >> 5) % 257;
    if (pmo[0].empty()) pmo[0].push_back(1), pmo[1].push_back(1);
    for (i = 0; i < (l); i++)
      hash_[0].push_back((hash_[0].back() * mul0 + add0 + s[i]) % mo0);
  }
  pair<signed long long, signed long long> hash(int l, int r) {
    if (l > r) return make_pair(0, 0);
    while (pmo[0].size() < r + 2) pmo[0].push_back(pmo[0].back() * mul0 % mo0);
    return make_pair(
        (hash_[0][r + 1] + (mo0 - hash_[0][l] * pmo[0][r + 1 - l] % mo0)) % mo0,
        0);
    return make_pair(
        (hash_[0][r + 1] + (mo0 - hash_[0][l] * pmo[0][r + 1 - l] % mo0)) % mo0,
        (hash_[1][r + 1] + (mo1 - hash_[1][l] * pmo[1][r + 1 - l] % mo1)) %
            mo1);
  }
  static pair<signed long long, signed long long> concat(
      pair<signed long long, signed long long> L,
      pair<signed long long, signed long long> R, int RL) {
    while (pmo[0].size() < RL + 2)
      pmo[0].push_back(pmo[0].back() * mul0 % mo0), pmo[1].push_back(0);
    return make_pair((R.first + L.first * pmo[0][RL]) % mo0, 0);
  }
};
vector<signed long long> RollingHash::pmo[2];
signed long long RollingHash::mul0, RollingHash::mul1;
int N;
string S[101010];
deque<int> Q[101010];
vector<signed long long> dp[101010];
RollingHash rh[101010];
const signed long long mo = 1000000007;
pair<signed long long, signed long long> gethash(int i, int p, int len) {
  if (len <= p) {
    return rh[i].hash(0, len - 1);
  }
  pair<signed long long, signed long long> L = rh[i].hash(0, p - 1);
  pair<signed long long, signed long long> R = rh[i].hash(p + 1, len);
  return rh[i].concat(L, R, len - p);
}
int comp(int i, int p, int j, int q) {
  int a = (int)S[i].size() - (p < S[i].size());
  int b = (int)S[j].size() - (q < S[j].size());
  int ml = min(a, b);
  int cur = 0;
  int x;
  for (x = 20; x >= 0; x--)
    if (cur + (1 << x) <= ml) {
      auto L = gethash(i, p, cur + (1 << x));
      auto R = gethash(j, q, cur + (1 << x));
      if (L == R) cur += 1 << x;
    }
  if (cur == ml) {
    return a <= b;
  } else {
    char c = S[i][cur + (cur >= p)];
    char d = S[j][cur + (cur >= q)];
    return c <= d;
  }
}
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  cin >> N;
  Q[0].push_back(0);
  dp[0].push_back(1);
  rh[0].init(S[0]);
  for (i = 0; i < (N); i++) {
    cin >> S[i + 1];
    rh[i + 1].init(S[i + 1]);
    dp[i + 1].resize(S[i + 1].size() + 1);
    vector<vector<int>> cand;
    j = 0;
    while (j < S[i + 1].size()) {
      cand.push_back({0, j, 1});
      x = j + 1;
      while (x < S[i + 1].size() && S[i + 1][j] == S[i + 1][x])
        x++, cand.back()[2]++;
      if (x == S[i + 1].size() || S[i + 1][j] > S[i + 1][x]) cand.back()[0] = 1;
      j = x;
    }
    reverse((cand.begin()), (cand.end()));
    Q[i + 1].push_back(S[i + 1].size());
    for (auto& c : cand) {
      if (c[0]) {
        for (j = 0; j < (c[2]); j++) Q[i + 1].push_front(c[1] + j);
      } else {
        for (j = 0; j < (c[2]); j++) Q[i + 1].push_back(c[1] + j);
      }
    }
    int p = 0, q;
    signed long long sum = 0;
    for (q = 0; q < (Q[i + 1].size()); q++) {
      while (p < Q[i].size() && comp(i, Q[i][p], i + 1, Q[i + 1][q]))
        (sum += dp[i][p++]) %= mo;
      dp[i + 1][q] = sum;
    }
  }
  signed long long sum = 0;
  for (auto& d : dp[N]) sum += d;
  cout << sum % mo << endl;
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);
  for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);
  cout.tie(0);
  solve();
  return 0;
}
