#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
template <class T = int>
T __rand(T range = numeric_limits<T>::max()) {
  return (T)(rng() % range);
}
template <class T>
ostream& operator,(ostream& out, const T& thing) {
  return out << ", " << thing;
}
template <class U, class V>
ostream& operator<<(ostream& out, const pair<U, V>& p) {
  return (out << "(" << p.first, p.second) << ")";
}
template <class A, class B>
ostream& operator<<(ostream& out, const tuple<A, B>& t) {
  return (out << "(" << get<0>(t), get<1>(t)) << ")";
}
template <class A, class B, class C>
ostream& operator<<(ostream& out, const tuple<A, B, C>& t) {
  return (out << "(" << get<0>(t), get<1>(t), get<2>(t)) << ")";
}
template <class T>
ostream& operator<<(ostream& out, const vector<T>& container) {
  out << "{";
  if (((int)container.size())) out << container[0];
  for (int i = 0; i++ < ((int)container.size()) - 1;) out, container[i];
  return out << "}";
}
template <class x>
vector<typename x::value_type> $v(const x& a) {
  return vector<typename x::value_type>(a.begin(), a.end());
}
template <class u>
vector<typename iterator_traits<u>::value_type> $v(u a, u b) {
  return vector<typename iterator_traits<u>::value_type>(a, b);
}
function<bool(int, int)> gen_missing_char_cmp(const string& su,
                                              const string& sv) {
  using sitor = string::const_iterator;
  static auto gen_diff = [](sitor bu, sitor eu, sitor bv, sitor ev) {
    int lu = (int)(eu - bu), lv = (int)(ev - bv);
    int l = min(lu, lv);
    vector<int> ans(l + 1);
    ans.back() = l;
    int prev = l;
    for (int i = l; i--;) {
      if (bu[i] == bv[i])
        ans[i] = prev;
      else
        prev = ans[i] = i;
    }
    return ans;
  };
  static vector<int> first_diff, miss1_first_diff, miss2_first_diff;
  first_diff = gen_diff(su.begin(), su.end(), sv.begin(), sv.end());
  miss1_first_diff = gen_diff(su.begin() + 1, su.end(), sv.begin(), sv.end());
  miss2_first_diff = gen_diff(su.begin(), su.end(), sv.begin() + 1, sv.end());
  return [&su, &sv](int u, int v) {
    auto cmp_char = [&](int x, int y) {
      char cu = x >= ((int)su.size()) ? ' ' : su[x];
      char cv = y >= ((int)sv.size()) ? ' ' : sv[y];
      return cu < cv;
    };
    if (int t = first_diff[0]; t < min(u, v)) return cmp_char(t, t);
    if (u < v) {
      if (int t = miss1_first_diff[u]; t < v) return cmp_char(t + 1, t);
    } else {
      if (int t = miss2_first_diff[v]; t < u) return cmp_char(t, t + 1);
    }
    int t = first_diff[max(u, v) + 1];
    return cmp_char(t, t);
  };
}
const long long mod = (long long)1e9 + 7;
const int maxn = 101010;
int n;
string s[maxn];
vector<int> mchs[maxn];
vector<long long> dp[maxn];
int main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = -1; ++i < n;) {
    ;
    cin >> s[i];
    s[i] += ' ';
    ;
    for (int f = -1; ++f < ((int)s[i].size());) mchs[i].push_back(f);
    auto cur_cmp = gen_missing_char_cmp(s[i], s[i]);
    sort(mchs[i].begin(), mchs[i].end(), cur_cmp);
    if (i == 0) {
      dp[i].resize(((int)s[i].size()), 1);
      continue;
    }
    dp[i].resize(((int)s[i].size()));
    long long sum_prev = 0;
    int u = 0;
    auto cmp = gen_missing_char_cmp(s[i], s[i - 1]);
    for (int v = -1; ++v < ((int)s[i].size());) {
      while (u < ((int)s[i - 1].size()) and
             !(cmp(mchs[i][v], mchs[i - 1][u]))) {
        sum_prev += dp[i - 1][u];
        if (sum_prev >= mod) sum_prev -= mod;
        ++u;
      }
      dp[i][v] = sum_prev;
    };
  }
  long long ans = 0;
  for (auto& i : dp[n - 1]) {
    ans += i;
    if (ans >= mod) ans -= mod;
  }
  cout << ans;
  return 0;
}
