#include <bits/stdc++.h>
using namespace std;
const unsigned long long int seed = 50009uLL;
string s[(1010)];
vector<unsigned long long int> h[(1010)];
long long int cnt[(1010)];
unsigned long long int xp[(20020)];
void init_xp(int n) {
  xp[0] = 1;
  for (int i = 1; i < n; i++) xp[i] = xp[i - 1] * seed;
}
void init_hash(int k) {
  string &s_ = s[k];
  h[k].clear();
  h[k].push_back(s_[0] - 'a' + 1);
  for (int i = 1, sz = s_.size(); i < sz; i++) {
    h[k].push_back(h[k][i - 1] * seed +
                   (unsigned long long int)(s_[i] - 'a' + 1));
  }
}
unsigned long long int ask_hash(int k, int l, int r) {
  if (l > r) return 0;
  if (!l) return h[k][r];
  return h[k][r] - h[k][l - 1] * xp[r - l + 1];
}
unsigned long long int cal_hash(int k, int x, int n) {
  if (-1 == x || x > n) {
    return ask_hash(k, 0, n);
  }
  n++;
  return ask_hash(k, 0, x - 1) * xp[n - x] + ask_hash(k, x + 1, n);
}
struct node {
  int i, j;
  bool operator<(const node &o) const {
    string &a = s[i], &b = s[o.i];
    int lena = a.size() - int(j > -1), lenb = b.size() - int(o.j > -1);
    int mx = min(lena, lenb) - 1;
    int l = 0, r = mx, k = -1;
    while (l <= r) {
      int m = (l + r) >> 1;
      unsigned long long int ha = cal_hash(i, j, m), hb = cal_hash(o.i, o.j, m);
      if (ha == hb) {
        k = m;
        l = m + 1;
      } else {
        r = m - 1;
      }
    }
    if (mx == k) {
      if (lena == lenb) return i < o.i;
      return lena < lenb;
    }
    char ca = (j != -1 && j <= k + 1) ? a[k + 2] : a[k + 1];
    char cb = (o.j != -1 && o.j <= k + 1) ? b[k + 2] : b[k + 1];
    return ca < cb;
  }
};
vector<node> v;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  init_xp((20020));
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    init_hash(i);
    v.push_back((node){i, -1});
    for (int j = 0, sz = s[i].size(); j < sz; j++) {
      v.push_back((node){i, j});
    }
  }
  sort(v.begin(), v.end());
  for (int i = 0, sz = v.size(); i < sz; i++) {
    if (1 == v[i].i)
      cnt[1]++;
    else
      cnt[v[i].i] += cnt[v[i].i - 1];
    cnt[v[i].i] %= (1000000007);
  }
  cout << cnt[n] << endl;
  return 0;
}
