#include <bits/stdc++.h>
#pragma GCC optimize("O3,no-stack-protector")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
vector<int> DropSort(const string& str) {
  int t = 0;
  vector<int> nv(str.size(), -1);
  for (int i = 1; i < str.size(); ++i) {
    if (str[i] != str[t]) {
      while (t != i) {
        nv[t++] = i;
      }
    }
  }
  vector<int> res(str.size());
  int l = 0;
  int r = str.size() - 1;
  for (int i = 0; i < str.size(); ++i) {
    if (nv[i] != -1 and str[i] < str[nv[i]]) {
      res[r--] = i;
    } else {
      res[l++] = i;
    }
  }
  res.insert(next(find(begin(res), end(res), str.size() - 1)), str.size());
  return res;
}
vector<int64_t> HashSum(const string& str, const vector<int64_t>& pows,
                        int64_t kMod) {
  vector<int64_t> res(str.size(), 0);
  for (int i = 0; i < str.size(); ++i) {
    res[i] = (pows[i] * str[i]) % kMod;
  }
  for (int i = 1; i < str.size(); ++i) {
    res[i] = (res[i] + res[i - 1]) % kMod;
  }
  return res;
}
constexpr int64_t kMod = 1000000007;
struct Solver {
  vector<string> vec;
  vector<vector<int>> drop_sorts;
  vector<int64_t> p29, p31;
  vector<vector<vector<int64_t>>> hs;
  void Read() {
    int len;
    cin >> len;
    vec.resize(len);
    for (auto&& e : vec) {
      cin >> e;
    }
    drop_sorts.resize(len);
    hs.resize(len);
  }
  void Init() {
    size_t max_len = 0;
    for (int i = 0; i < vec.size(); ++i) {
      max_len = max(max_len, vec[i].size());
      drop_sorts[i] = DropSort(vec[i]);
    }
    p29.resize(max_len);
    p31.resize(max_len);
    p29[0] = 1;
    p31[0] = 1;
    for (int i = 1; i < max_len; ++i) {
      p29[i] = (p29[i - 1] * 29) % kMod;
      p31[i] = (p31[i - 1] * 31) % kMod;
    }
    for (int i = 0; i < vec.size(); ++i) {
      hs[i].resize(2);
      hs[i][0] = HashSum(vec[i], p29, kMod);
      hs[i][1] = HashSum(vec[i], p31, kMod);
    }
  }
  pair<int64_t, int64_t> GetHash(int i, int j, int pos) {
    if (pos >= j) {
      int64_t h1 = (hs[i][0][pos + 1] + kMod - hs[i][0][j]) % kMod;
      if (j > 0) {
        h1 = (h1 + hs[i][0][j - 1] * 29) % kMod;
      }
      int64_t h2 = (hs[i][1][pos + 1] + kMod - hs[i][1][j]) % kMod;
      if (j > 0) {
        h2 = (h2 + hs[i][1][j - 1] * 31) % kMod;
      }
      return {h1, h2};
    }
    int64_t h1 = (hs[i][0][pos] * 29) % kMod;
    int64_t h2 = (hs[i][1][pos] * 31) % kMod;
    return {h1, h2};
  }
  char GetChar(int i, int j, int pos) {
    if (pos >= j) {
      ++pos;
    }
    return vec[i][pos];
  }
  void Solve() {
    Read();
    Init();
    vector<int64_t> sv(vec.back().size() + 1, 1);
    for (int i = vec.size() - 1; i-- > 0;) {
      vector<int64_t> nsv(vec[i].size() + 1, 0);
      const auto& av = drop_sorts[i];
      const auto& bv = drop_sorts[i + 1];
      int bi = bv.size() - 1;
      int64_t count = 0;
      for (int ai = av.size(); ai-- > 0;) {
        while (bi >= 0) {
          int len_ai = vec[i].size() - (av[ai] == vec[i].size() ? 0 : 1);
          int len_bi =
              vec[i + 1].size() - (bv[bi] == vec[i + 1].size() ? 0 : 1);
          int b = 0;
          int e = min(len_ai, len_bi);
          if (GetHash(i, av[ai], b) != GetHash(i + 1, bv[bi], b)) {
            e = b;
          }
          while ((e - b) > 1) {
            int m = (e + b) / 2;
            if (GetHash(i, av[ai], m) == GetHash(i + 1, bv[bi], m)) {
              b = m;
            } else {
              e = m;
            }
          }
          bool leq;
          if (e < min(len_ai, len_bi)) {
            leq = GetChar(i, av[ai], e) < GetChar(i + 1, bv[bi], e);
          } else {
            leq = (len_ai <= len_bi);
          }
          if (leq) {
            count = (count + sv[bv[bi]]) % kMod;
            --bi;
          } else {
            break;
          }
        }
        nsv[av[ai]] = count;
      }
      sv = nsv;
    }
    int64_t count = 0;
    for (auto& x : sv) {
      count = (count + x) % kMod;
    }
    cout << count << '\n';
  }
};
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  Solver().Solve();
  return 0;
}
