#include <bits/stdc++.h>
using namespace std;
mt19937 rnd((size_t)time(nullptr));
long long B = 41;
long long MOD = 1000000007;
long long rBASE;
vector<vector<int>> s_i;
vector<vector<long long>> h_s;
vector<string> a;
long long in_pow(long long a, long long b) {
  if (b == 0) {
    return 1;
  }
  if (b == 1) {
    return a;
  }
  if (b % 2) {
    return (a * in_pow((a * a) % MOD, b / 2)) % MOD;
  } else {
    return in_pow((a * a) % MOD, b / 2);
  }
}
long long get_hash(int id, int rs, int len) {
  len--;
  if (rs > len) {
    return h_s[id][len];
  }
  long long hash = h_s[id][rs - 1];
  hash += (h_s[id][len + 1] - h_s[id][rs] + MOD) * rBASE;
  hash %= MOD;
  return hash;
}
bool is_le_1(int id_1, int rs_1, int id_2, int rs_2) {
  int l = 0, r = min(a[id_1].size(), a[id_2].size());
  while (r > l + 1) {
    int m = (l + r) / 2;
    if (get_hash(id_1, rs_1, m) == get_hash(id_2, rs_2, m)) {
      l = m;
    } else {
      r = m;
    }
  }
  int l_1 = l;
  int l_2 = l;
  if (l_1 == rs_1) {
    l_1++;
  }
  if (l_2 == rs_2) {
    l_2++;
  }
  if (l_1 == a[id_1].size()) {
    return true;
  }
  if (l_2 == a[id_2].size()) {
    return false;
  }
  return a[id_1][l_1] <= a[id_2][l_2];
}
bool is_le(int id_1, int rs_1, int id_2, int rs_2) {
  string s1 = a[id_1];
  string s2 = a[id_2];
  s1.pop_back();
  s2.pop_back();
  if (rs_1 < s1.size()) s1.erase(rs_1, 1);
  if (rs_2 < s2.size()) s2.erase(rs_2, 1);
  return s1 <= s2;
  int i_1 = 0, i_2 = 0;
  while (true) {
    if (i_1 == rs_1) {
      ++i_1;
    }
    if (i_2 == rs_2) {
      ++i_2;
    }
    if (i_1 == a[id_1].size() - 1) {
      return true;
    }
    if (i_2 == a[id_2].size() - 1) {
      return false;
    }
    if (a[id_1][i_1] < a[id_2][i_2]) {
      return true;
    }
    if (a[id_1][i_1] > a[id_2][i_2]) {
      return false;
    }
    i_1++;
    i_2++;
  }
}
int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  a.resize(n);
  s_i.resize(n);
  h_s.resize(n);
  rBASE = in_pow(B, MOD - 2);
  for (int cs = 0; cs < n; ++cs) {
    cin >> a[cs];
    a[cs].push_back((char)0);
    string &s = a[cs];
    vector<int> rev_st;
    vector<int> nxt(s.size() - 1);
    for (int i = s.size() - 2; i >= 0; i--) {
      if (s[i] == s[i + 1]) {
        nxt[i] = nxt[i + 1];
      } else {
        nxt[i] = i + 1;
      }
    }
    vector<int> &m_s = s_i[cs];
    for (int i = 0; i < s.size() - 1; ++i) {
      if (s[i] > s[nxt[i]]) {
        m_s.push_back(i);
      } else {
        rev_st.push_back(i);
      }
    }
    m_s.push_back(s.size() - 1);
    while (rev_st.size() > 0) {
      m_s.push_back(rev_st.back());
      rev_st.pop_back();
    }
    h_s[cs].resize(s.size());
    for (int i = 0; i < s.size(); ++i) {
      if (i == 0) {
        h_s[cs][i] = s[i] - 'a';
      } else {
        h_s[cs][i] = (h_s[cs][i - 1] * B + s[i] - 'a') % MOD;
      }
    }
  }
  vector<vector<long long>> dp(n);
  dp[0].resize(s_i[0].size());
  for (int i = 0; i < s_i[0].size(); ++i) {
    dp[0][i] = 1;
  }
  for (int i = 1; i < n; ++i) {
    int li = 0;
    long long cur_s = 0;
    dp[i].resize(s_i[i].size());
    for (int j = 0; j < s_i[i].size(); j++) {
      while (li < s_i[i - 1].size()) {
        if (is_le(i - 1, s_i[i - 1][li], i, s_i[i][j])) {
          cur_s += dp[i - 1][li];
          cur_s %= MOD;
          li++;
        } else {
          break;
        }
      }
      dp[i][j] = cur_s;
    }
  }
  long long ans = 0;
  for (long long vl : dp[n - 1]) {
    ans += vl;
    ans %= MOD;
  }
  cout << ans;
  return 0;
}
