#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const int MAX = 1e5 + 10;
const int MOD = 1e9 + 7;
int n;
string s[MAX];
vector<int> dp[MAX];
vector<int> ord[MAX];
vector<int> lcp[MAX], lcp_l[MAX], lcp_r[MAX];
vector<int> lcp_self[MAX];
void pre_lcp() {
  for (int i = 0; i < n - 1; i++) {
    {
      int ans = 0;
      for (int j = 0; j < s[i].size(); j++) {
        ans = max(0, ans - 1);
        while (j + ans < s[i + 1].size() and s[i + 1][j + ans] == s[i][j + ans])
          ans++;
        lcp[i][j] = ans;
      }
    }
    {
      int ans = 0;
      for (int j = 0; j < s[i].size(); j++) {
        ans = max(0, ans - 1);
        while (j + 1 + ans < s[i + 1].size() and
               s[i + 1][j + 1 + ans] == s[i][j + ans])
          ans++;
        lcp_l[i][j] = ans;
      }
    }
    {
      int ans = 0;
      for (int j = 0; j < s[i].size(); j++) {
        ans = max(0, ans - 1);
        while (j - 1 + ans >= 0 and j - 1 + ans < s[i + 1].size() and
               s[i + 1][j - 1 + ans] == s[i][j + ans])
          ans++;
        lcp_r[i][j] = ans;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    int ans = 0;
    for (int j = 0; j < s[i].size(); j++) {
      ans = max(0, ans - 1);
      while (j + ans < s[i].size() and s[i][j + ans] == s[i][j]) ans++;
      lcp_self[i][j] = ans;
    }
  }
}
bool comp(int i, int vi, int vj) {
  auto cmp = [&](char a, char b) -> bool {
    if (a == '#' and b == '!') return 1;
    return a < b;
  };
  if (lcp[i][0] < min(vi, vj)) return cmp(s[i][lcp[i][0]], s[i + 1][lcp[i][0]]);
  if (vi == vj) {
    int at = vi + 1 + lcp[i][vi + 1];
    if (at == s[i].size()) return 1;
    return cmp(s[i][at], s[i + 1][at]);
  }
  if (vi < vj) {
    int at = vi + 1 + lcp_r[i][vi + 1];
    if (at <= vj) return s[i][at] < s[i + 1][at - 1];
    int at2 = vj + 1 + lcp[i][vj + 1];
    if (at2 == s[i].size()) return 1;
    return cmp(s[i][at2], s[i + 1][at2]);
  } else {
    int at = vj + lcp_l[i][vj];
    if (at < vi) return s[i][at] < s[i + 1][at + 1];
    int at2 = vi + 1 + lcp[i][vi + 1];
    if (at2 == s[i].size()) return 1;
    return cmp(s[i][at2], s[i + 1][at2]);
  }
}
int comp_self(int i, int vi, int vj) {
  if (vi == vj) return 0;
  if (vi > vj) {
    int at = vj + lcp_self[i][vj] - 1;
    if (at < vi) return s[i][at] < s[i][at + 1];
  } else {
    int at = vi + lcp_self[i][vi] - 1;
    if (at < vj) return s[i][at] > s[i][at + 1];
  }
  return 0;
}
void solve(int x) {
  if (x == n - 1) {
    for (int i = 0; i < s[x].size() - 1; i++) dp[x].push_back(1);
    return;
  }
  solve(x + 1);
  int sum = 0;
  int j = s[x + 1].size() - 2;
  for (int i = s[x].size() - 2; i >= 0; i--) {
    while (j >= 0 && comp(x, ord[x][i], ord[x + 1][j])) {
      sum = (sum + dp[x + 1][j]) % MOD;
      j--;
    }
    dp[x].push_back(sum);
  }
  reverse(dp[x].begin(), dp[x].end());
}
const int base = 31;
const int inv_base = 129032259;
long long pbase[MAX];
struct string_wrap {
  string_wrap() {}
  string s;
  int n, rem;
  vector<long long> h;
  string_wrap(string s_) : s(s_) {
    n = s.size();
    rem = INF;
    h.resize(n + 1, 0);
    for (int i = 1; i <= n; i++)
      h[i] = (h[i - 1] + pbase[i] * (s[i - 1] - 'a' + 1)) % MOD;
  };
  void erase(int k) { rem = k; }
  long long hash(int r) {
    if (r == -1) return 0;
    if (r < rem)
      return h[r + 1];
    else {
      long long L = h[rem];
      long long R = (h[r + 2] - h[rem + 1] + MOD) * inv_base % MOD;
      return (L + R) % MOD;
    }
  }
  int size() { return n - (rem != INF); }
  void reset() { rem = INF; }
  char at(int x) {
    if (x < rem)
      return s[x];
    else
      return s[x + 1];
  }
  void print() {
    for (int i = 0; i < n; i++)
      if (i != rem) cout << s[i];
  }
};
vector<int> memo[MAX];
bool cmp_less_eq(string_wrap &sl, string_wrap &sr) {
  int sz = min(sl.size(), sr.size());
  int l = 0, r = sz - 1;
  while (l <= r) {
    int m = (l + r) / 2;
    long long hl = sl.hash(m - 1);
    long long hr = sr.hash(m - 1);
    if (hl != hr) {
      r = m - 1;
    } else {
      if (sl.at(m) != sr.at(m)) {
        return sl.at(m) <= sr.at(m);
      }
      l = m + 1;
    }
  }
  return sl.size() <= sr.size();
}
int solve(int prev, int curr) {
  if (curr == n) return 1;
  int &ans = memo[curr][prev + 1];
  if (ans != -1) return ans;
  ans = 0;
  string_wrap sa;
  if (curr == 0)
    sa = string_wrap("");
  else
    sa = string_wrap(s[curr - 1]);
  if (prev != -1) sa.erase(prev);
  string_wrap sb(s[curr]);
  if (cmp_less_eq(sa, sb)) ans += solve(-1, curr + 1);
  for (int j = 0; j < sb.size(); j++) {
    sb.erase(j);
    if (cmp_less_eq(sa, sb)) {
      ans += solve(j, curr + 1);
      if (ans >= MOD) ans -= MOD;
    }
    sb.reset();
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  if (n <= 10) {
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      s[i] += '#';
      s[i] += '!';
      lcp[i].resize(s[i].size());
      lcp_l[i].resize(s[i].size());
      lcp_r[i].resize(s[i].size());
      lcp_self[i].resize(s[i].size());
    }
    pre_lcp();
    for (int i = 0; i < n; i++) {
      vector<int> at(s[i].size() - 1);
      iota(at.begin(), at.end(), 0);
      sort(at.begin(), at.end(),
           [&](int a, int b) { return comp_self(i, a, b); });
      for (int j : at) ord[i].push_back(j);
    }
    solve(0);
    int ret = 0;
    for (auto x : dp[0]) ret = (ret + x) % MOD;
    cout << ret << '\n';
  } else {
    pbase[0] = 1;
    for (int i = 1; i < MAX; i++) pbase[i] = (pbase[i - 1] * base) % MOD;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      if (i)
        memo[i] = vector<int>(s[i - 1].size() + 10, -1);
      else
        memo[i] = vector<int>(1, -1);
    }
    cout << solve(-1, 0) << '\n';
  }
  exit(0);
}
