#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 = 0;
  for (int i = 0; i < s[x].size() - 1; i++) {
    while (j < s[x + 1].size() - 1 && comp(x, ord[x][i], ord[x + 1][j])) {
      sum = (sum + dp[x + 1][j]) % MOD;
      j++;
    }
    dp[x].push_back(sum);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  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); });
    reverse(at.begin(), at.end());
    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';
  exit(0);
}
