#include <bits/stdc++.h>
using namespace std;
template <typename T>
void __read(T &a) {
  cin >> a;
}
template <typename T, typename... Args>
void __read(T &a, Args &...args) {
  cin >> a;
  __read(args...);
}
constexpr long long M7 = 1000000007ll;
constexpr long long M9 = 1000000009ll;
constexpr long long MFFT = 998244353ll;
template <class T>
void outv(const T &a) {
  for (auto &x : a) cout << x << ' ';
}
static mt19937 rnd(static_cast<unsigned>(
    chrono::steady_clock::now().time_since_epoch().count()));
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr));
template <class T, class F>
void cntSort(vector<T> &a, int mx, F f) {
  vector<int> cnt(mx + 1);
  for (auto &v : a) {
    cnt[f(v)]++;
  }
  for (int i = 0; i < mx; ++i) {
    cnt[i + 1] += cnt[i];
  }
  vector<T> b(a.size());
  for (int i = (int)a.size() - 1; i >= 0; --i) {
    b[--cnt[f(a[i])]] = a[i];
  }
  a = move(b);
}
vector<int> sufArray(const string &s) {
  int n = s.length();
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    a[i] = s[i];
  }
  vector<tuple<int, int, int>> b(n);
  for (int len = 1; len < n; len *= 2) {
    for (int i = 0; i < n; ++i) {
      b[i] = {a[i], a[(i + len) % n], i};
    }
    cntSort(b, max(128, n - 1),
            [](const tuple<int, int, int> &a) { return get<1>(a); });
    cntSort(b, max(128, n - 1),
            [](const tuple<int, int, int> &a) { return get<0>(a); });
    a[get<2>(b[0])] = 0;
    for (int i = 1; i < n; ++i) {
      a[get<2>(b[i])] = a[get<2>(b[i - 1])];
      if (get<0>(b[i]) != get<0>(b[i - 1]) ||
          get<1>(b[i]) != get<1>(b[i - 1])) {
        a[get<2>(b[i])]++;
      }
    }
  }
  return a;
}
vector<int> buildLcp(const string &s, const vector<int> &suf) {
  int n = s.length();
  vector<int> l(n - 1);
  vector<int> pos(n);
  for (int i = 0; i < n; ++i) {
    pos[suf[i]] = i;
  }
  for (int i = 0; i < n; ++i) {
    if (suf[i] + 1 == n) {
      continue;
    }
    int ni = pos[suf[i] + 1];
    int j = suf[i];
    if (i > 0) {
      l[j] = max(1, suf[i - 1] + 1 == n ? 1 : l[suf[i - 1]]) - 1;
    }
    while (max(i, ni) + l[j] < n && s[i + l[j]] == s[ni + l[j]]) {
      l[j]++;
    }
  }
  return l;
}
int32_t main() {
  int n;
  __read(n);
  vector<string> a(n);
  string s;
  vector<int> spos(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i].push_back('$');
    spos[i] = s.length();
    s += a[i];
  }
  s.push_back('$' - 1);
  vector<int> sf = sufArray(s);
  vector<int> lcp = buildLcp(s, sf);
  const int LOG = 20;
  vector<int> lg(1 << LOG);
  for (int i = 2; i < lg.size(); ++i) {
    lg[i] = lg[i / 2] + 1;
  }
  vector<vector<int>> st(1, lcp);
  for (int l = 1; (1 << l) < lcp.size(); ++l) {
    int len = 1 << l;
    st.push_back(vector<int>(lcp.size() - len + 1));
    for (int i = 0; i < st.back().size(); ++i) {
      st[l][i] = min(st[l - 1][i], st[l - 1][i + len / 2]);
    }
  }
  auto minQuery = [&](int l, int r) {
    int i = lg[r - l + 1];
    return min(st[i][l], st[i][r - (1 << i) + 1]);
  };
  auto maxPref = [&](int i, int j) {
    int l = sf[i];
    int r = sf[j];
    if (l > r) {
      swap(l, r);
    }
    return minQuery(l, r - 1);
  };
  vector<vector<int>> ne(n);
  vector<vector<int>> ord(n);
  for (int i = 0; i < n; ++i) {
    ne[i].resize(a[i].length());
    ne[i].back() = a[i].length();
    for (int j = (int)(ne[i].size()) - 2; j >= 0; --j) {
      ne[i][j] = (a[i][j] == a[i][j + 1] ? ne[i][j + 1] : j + 1);
    }
    for (int j = 0; j + 1 < a[i].size(); ++j) {
      if (a[i][j] > a[i][ne[i][j]]) {
        ord[i].push_back(j);
      }
    }
    ord[i].push_back((int)(a[i].size()) - 1);
    for (int j = (int)a[i].size() - 2; j >= 0; --j) {
      if (a[i][j] < a[i][ne[i][j]]) {
        ord[i].push_back(j);
      }
    }
  }
  vector<vector<int>> dp(n);
  dp[n - 1].resize(a[n - 1].size());
  for (int j = 0; j < ord[n - 1].size(); ++j) {
    dp[n - 1][j] = 1;
  }
  for (int i = (int)dp[n - 1].size() - 2; i >= 0; --i) {
    dp[n - 1][i] += dp[n - 1][i + 1];
  }
  for (int i = n - 2; i >= 0; --i) {
    dp[i].resize(a[i].size());
    for (int ind = 0; ind < ord[i].size(); ++ind) {
      int j = ord[i][ind];
      int l = 0, r = a[i + 1].size();
      while (l < r) {
        int mid = l + (r - l) / 2;
        int j2 = ord[i + 1][mid];
        int pos1 = spos[i];
        int pos2 = spos[i + 1];
        int len = min({maxPref(pos1, pos2), j, j2});
        if (len == min(j, j2)) {
          int d = max(j2, j) - min(j2, j);
          len += min(maxPref(pos1 + len + (len >= j ? 1 : 0),
                             pos2 + len + (len >= j2 ? 1 : 0)),
                     d);
          if (len == max(j, j2)) {
            len += maxPref(pos1 + len + 1, pos2 + len + 1);
          }
        }
        len = min({len, (int)a[i].length() - 1, (int)a[i + 1].length() - 1});
        int jj1 = len + (len >= j ? 1 : 0);
        int jj2 = len + (len >= j2 ? 1 : 0);
        char q1 = jj1 == a[i].size() ? '$' : a[i][jj1];
        char q2 = jj2 == a[i + 1].size() ? '$' : a[i + 1][jj2];
        if (q2 >= q1) {
          r = mid;
        } else {
          l = mid + 1;
        }
      }
      if (r != a[i + 1].size()) {
        dp[i][ind] = dp[i + 1][r];
      }
    }
    for (int j = (int)(a[i].size()) - 2; j >= 0; --j) {
      dp[i][j] = (dp[i][j] + dp[i][j + 1]) % M7;
      assert(dp[i][j] >= 0);
    }
  }
  cout << dp[0][0];
  return 0;
}
