#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7, N = 1000100;
int n;
struct Cmp {
  int m;
  int d[N], ds[N], dt[N];
  int posd[N], posds[N], posdt[N];
  void work(int *_d, int n, int *pos_d) {
    for (int i = 0; i < n; ++i) pos_d[i] = n;
    for (int i = n - 1; i >= 0; --i) {
      if (i + 1 < n) pos_d[i] = pos_d[i + 1];
      if (_d[i] != 0) pos_d[i] = i;
    }
  }
  void init(string &s, string &t) {
    m = s.size();
    for (int i = 0; i < m; ++i) {
      d[i] = s[i] - t[i];
      if (i + 1 < m) {
        ds[i] = s[i + 1] - t[i];
        dt[i] = s[i] - t[i + 1];
      }
    }
    work(d, m, posd);
    work(ds, m - 1, posds);
    work(dt, m - 1, posdt);
  }
  int sign(int x) { return x < 0 ? -1 : 1; }
  int check(int i, int j) {
    int x = min(i, j);
    if (posd[0] < x) return sign(d[posd[0]]);
    if (i == j) {
      if (i + 1 == m) return 0;
      if (posd[i + 1] == m) return 0;
      return sign(d[posd[i + 1]]);
    }
    if (i < j) {
      if (posds[i] < j) return sign(ds[posds[i]]);
      if (j + 1 == m) return 0;
      if (posd[j + 1] == m) return 0;
      return sign(d[posd[j + 1]]);
    } else {
      if (posdt[j] < i) return sign(dt[posdt[j]]);
      if (i + 1 == m) return 0;
      if (posd[i + 1] == m) return 0;
      return sign(d[posd[i + 1]]);
    }
  }
} cmp[4];
vector<pair<int, int> > chk;
bool CMP(const pair<int, int> &aa, const pair<int, int> &bb) {
  int x = cmp[aa.second * 2 + bb.second].check(aa.first, bb.first);
  if (x != 0) return x < 0;
  return aa.second < bb.second;
}
int main() {
  cin >> n;
  string s = "#", t;
  vector<int> f = {1};
  for (int i = 0; i < n; ++i) {
    cin >> t;
    t.push_back('#');
    vector<int> g(t.size());
    while (s.size() < t.size()) s.push_back('#'), f.push_back(0);
    while (s.size() > t.size()) t.push_back('#'), g.push_back(0);
    cmp[0].init(s, s);
    cmp[1].init(s, t);
    cmp[2].init(t, s);
    cmp[3].init(t, t);
    chk.clear();
    int m = s.size();
    for (int i = 0; i < m; ++i) {
      chk.push_back(make_pair(i, 0));
      chk.push_back(make_pair(i, 1));
    }
    sort(chk.begin(), chk.end(), CMP);
    int sum = 0;
    for (int i = 0; i < chk.size(); ++i) {
      if (chk[i].second == 0)
        sum = (sum + f[chk[i].first]) % mod;
      else
        g[chk[i].first] = (g[chk[i].first] + sum) % mod;
    }
    swap(s, t), swap(f, g);
    while (s.size() >= 2 && s[s.size() - 2] == '#') {
      s.pop_back();
      f.pop_back();
    }
  }
  int ans = 0;
  for (int i = 0; i < f.size(); ++i) ans = (ans + f[i]) % mod;
  cout << (ans + mod) % mod;
  return 0;
}
