#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
struct suffixArray {
  string s;
  int n, alphabet;
  vector<int> p, c, cnt, rank, lcp;
  vector<vector<int> > st;
  suffixArray() {}
  suffixArray(string s) : s(s) {
    s += '$';
    n = s.size();
    alphabet = 256;
    p.resize(n, 0);
    c.resize(n, 0);
    cnt.resize(max(alphabet, n), 0);
    rank.resize(n - 1, 0);
    lcp.resize(n - 2, 0);
  }
  void build() {
    for (int i = 0; i < n; i++) cnt[s[i]]++;
    for (int i = 1; i < alphabet; i++) cnt[i] += cnt[i - 1];
    for (int i = 0; i < n; i++) p[--cnt[s[i]]] = i;
    c[p[0]] = 0;
    int classes = 1;
    for (int i = 1; i < n; i++) {
      if (s[p[i]] != s[p[i - 1]]) classes++;
      c[p[i]] = classes - 1;
    }
    vector<int> pn(n), cn(n);
    for (int h = 0; (1 << h) < n; h++) {
      for (int i = 0; i < n; i++) {
        pn[i] = p[i] - (1 << h);
        if (pn[i] < 0) pn[i] += n;
      }
      fill(cnt.begin(), cnt.begin() + classes, 0);
      for (int i = 0; i < n; i++) cnt[c[pn[i]]]++;
      for (int i = 1; i < classes; i++) cnt[i] += cnt[i - 1];
      for (int i = n - 1; i >= 0; i--) p[--cnt[c[pn[i]]]] = pn[i];
      cn[p[0]] = 0;
      classes = 1;
      for (int i = 1; i < n; i++) {
        if (c[p[i]] != c[p[i - 1]] ||
            c[p[i] + (1 << h) - (p[i] + (1 << h) < n ? 0 : n)] !=
                c[p[i - 1] + (1 << h) - (p[i - 1] + (1 << h) < n ? 0 : n)])
          classes++;
        cn[p[i]] = classes - 1;
      }
      swap(c, cn);
    }
    n--;
    p.erase(p.begin());
    return;
  }
  int lcp2(int l, int r) {
    l = rank[l];
    r = rank[r];
    if (l > r) swap(l, r);
    int T = r - l + 1;
    int lg = 31 - (__builtin_clz(T));
    return min(st[lg][l], st[lg][r - (1 << lg) + 1]);
  }
  void buildST() {
    st.push_back(vector<int>(n, -1));
    for (int i = 0; i < n; i++) st[0][i] = n - p[i];
    for (int h = 1; (1 << h) <= n; h++) {
      st.push_back(vector<int>(n, -1));
      for (int i = 0; i + (1 << h) - 1 < n; i++) {
        st[h][i] = min({st[h - 1][i], st[h - 1][i + (1 << (h - 1))],
                        lcp[i - 1 + (1 << (h - 1))]});
      }
    }
    return;
  }
  void lcp_construction() {
    for (int i = 0; i < n; i++) rank[p[i]] = i;
    int k = 0;
    for (int i = 0; i < n; i++) {
      if (rank[i] == n - 1) {
        k = 0;
        continue;
      }
      int j = p[rank[i] + 1];
      while (i + k < n && j + k < n && s[i + k] == s[j + k]) k++;
      lcp[rank[i]] = k;
      if (k) k--;
    }
    buildST();
    return;
  }
};
void add(int &a, int &b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
int ll, rr, lim;
suffixArray sa;
string cad[100001];
int acum[2][1000010];
bool cmp(int a, int b) {
  int L, R;
  if (a < lim) {
    L = ll;
  } else {
    L = lim + 1;
  }
  if (a != L) L++;
  if (b < lim) {
    R = ll;
  } else {
    R = lim + 1;
  }
  if (b != R) R++;
  int preffix = min(a - L, b - R);
  int common = sa.lcp2(L, R);
  if (common < preffix) return sa.rank[L] < sa.rank[R];
  if (a - L < b - R) {
    L = L + preffix + 1;
    R = R + preffix;
    preffix = b - R;
    common = sa.lcp2(L, R);
    if (common < preffix) return sa.rank[L] < sa.rank[R];
    L = L + preffix;
    R = R + preffix + 1;
  } else if (a - L > b - R) {
    L = L + preffix;
    R = R + preffix + 1;
    preffix = a - L;
    common = sa.lcp2(L, R);
    if (common < preffix) return sa.rank[L] < sa.rank[R];
    L = L + preffix + 1;
    R = R + preffix;
  } else {
    L = L + preffix + 1;
    R = R + preffix + 1;
  }
  return sa.rank[L] < sa.rank[R];
}
void solve(int lm, int posi) {
  int t = (posi & 1);
  vector<int> ord;
  for (int i = ll; i < rr; i++) {
    if (lm <= i && i <= lim) continue;
    ord.push_back(i);
  }
  sort(ord.begin(), ord.end(), cmp);
  int sum = 0;
  for (int i = 0; i < ord.size(); i++) {
    int pp = ord[i];
    if (pp < lim) {
      acum[t][pp - ll] = sum;
    } else if (pp > lim) {
      add(sum, acum[t ^ 1][pp - lim - 1]);
    }
  }
  return;
}
string tostring(int num) {
  string ans = "";
  while (num > 0) {
    ans += char(num % 10 + '0');
    num /= 10;
  }
  while (ans.size() < 5) ans += '0';
  reverse(ans.begin(), ans.end());
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout.precision(10);
  cout << fixed;
  vector<int> ini;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> cad[i];
  if (n == 1) {
    cout << cad[0].size() + 1 << "\n";
    return 0;
  }
  string s = "", numstr;
  for (int i = n - 1; i >= 0; i--) {
    ini.push_back(s.size());
    numstr = tostring(i);
    s += numstr;
    ini.push_back(s.size());
    s += cad[i] + "$";
    ini.push_back(s.size());
  }
  reverse(ini.begin(), ini.end());
  for (int i = 0; i <= cad[0].size(); i++) acum[0][i] = 1;
  sa = suffixArray(s);
  sa.build();
  sa.lcp_construction();
  int lm;
  for (int i = 0; i < n - 1; i++) {
    ll = ini[(i + 1) * 3 + 1] - 1;
    lm = ini[(i + 1) * 3] - 1;
    lim = ini[i * 3 + 1] - 2;
    rr = ini[i * 3] - 1;
    solve(lm, i + 1);
  }
  int t = ((n - 1) & 1);
  int ans = 0;
  for (int i = 0; i <= cad[n - 1].size(); i++) add(ans, acum[t][i]);
  cout << ans << "\n";
  return 0;
}
