#include <bits/stdc++.h>
const int N = 1e5 + 10, mod = 1e9 + 7;
std::string s[N];
std::vector<int> vec[N], f[N];
inline void upd(int &a, int b) { a = a + b >= mod ? a + b - mod : a + b; }
int main() {
  int n;
  std::cin >> n;
  for (int i = 0; i < n; ++i) std::cin >> s[i], s[i] += "#";
  for (int i = 0; i < n; ++i) {
    vec[i].resize(s[i].size()), f[i].resize(s[i].size());
    for (int j = 0; j < vec[i].size(); ++j) vec[i][j] = j;
    s[i] += '#';
  }
  for (int i = 0; i < f[0].size(); ++i) f[0][i] = 1;
  for (int i = 0; i < n; ++i) {
    std::vector<int> nex(vec[i].size());
    for (int j = vec[i].size() - 2; j >= 0; --j)
      nex[j] = s[i][j] == s[i][j + 1] ? nex[j + 1] : j;
    auto cmp = [&](int a, int b) {
      if (a > b) {
        int x1 = nex[b], x2 = x1 + 1;
        if (x1 < a) return s[i][x1] < s[i][x2];
        return false;
      } else {
        int x2 = nex[a], x1 = x2 + 1;
        if (x2 < b) return s[i][x1] < s[i][x2];
        return false;
      }
      return false;
    };
    std::sort(vec[i].begin(), vec[i].end(), cmp);
  }
  for (int i = 1; i < n; ++i) {
    int n = s[i - 1].size(), m = s[i].size();
    std::vector<int> nex1(std::min(n, m - 1));
    std::vector<int> nex2(std::min(n - 1, m));
    std::vector<int> nex(std::min(n, m));
    nex1[nex1.size() - 1] = nex1.size() - 1;
    for (int j = (int)nex1.size() - 2; j >= 0; --j)
      nex1[j] = s[i - 1][j] == s[i][j + 1] ? nex1[j + 1] : j;
    nex2[nex2.size() - 1] = nex2.size() - 1;
    for (int j = (int)nex2.size() - 2; j >= 0; --j)
      nex2[j] = s[i][j] == s[i - 1][j + 1] ? nex2[j + 1] : j;
    nex[nex.size() - 1] = nex.size() - 1;
    for (int j = (int)nex.size() - 2; j >= 0; --j)
      nex[j] = s[i][j] == s[i - 1][j] ? nex[j + 1] : j;
    auto cmp = [&](int a, int b) {
      if (nex[0] < std::min(a, b)) return s[i][nex[0]] < s[i - 1][nex[0]];
      if (a > b) {
        int x1 = nex2[b], x2 = x1 + 1;
        if (x1 < a) return s[i][x1] < s[i - 1][x2];
        return s[i][nex[a + 1]] < s[i - 1][nex[a + 1]];
      } else {
        int x2 = nex1[a], x1 = x2 + 1;
        if (x2 < b) return s[i][x1] < s[i - 1][x2];
        return s[i][nex[b + 1]] < s[i - 1][nex[b + 1]];
      }
      return false;
    };
    for (int j = 0, p = 0, sum = 0; j < vec[i].size(); ++j) {
      while (p < vec[i - 1].size() && !cmp(vec[i][j], vec[i - 1][p]))
        upd(sum, f[i - 1][p++]);
      f[i][j] = sum;
    }
  }
  int res = 0;
  for (int i = 0; i < f[n - 1].size(); ++i) upd(res, f[n - 1][i]);
  std::cout << res << std::endl;
  return 0;
}
