#include <bits/stdc++.h>
using namespace std;
long long read() {
  char ch = getchar();
  long long f = 1, x = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return f * x;
}
const long long P[2] = {33, 37}, MOD[2] = {20060527, 21071179}, MAXN = 1e3 + 10,
                ANSMOD = 1e9 + 7;
long long n, f[2][MAXN * 20], p[2][MAXN * 20];
long long sum[2][MAXN * 20] = {};
vector<pair<long long, long long> > myhsh[MAXN];
string str[MAXN];
void myhsh_generator(long long x) {
  long long ret[2] = {};
  long long sz = str[x].size();
  for (long long i = 0; i < sz; i++) {
    for (long long j = 0; j <= 1; j++) {
      ret[j] = (ret[j] * P[j] % MOD[j] + (long long)str[x][i]) % MOD[j];
    }
    myhsh[x].push_back(make_pair(ret[0], ret[1]));
  }
}
pair<long long, long long> consecutive_myhsh_query(long long x, long long l,
                                                   long long r) {
  if (l > r) {
    return make_pair(0, 0);
  }
  pair<long long, long long> ret =
      make_pair(myhsh[x][r].first, myhsh[x][r].second);
  if (l != 0) {
    ret.first = (ret.first - p[0][r - l + 1] * myhsh[x][l - 1].first % MOD[0] +
                 MOD[0]) %
                MOD[0];
    ret.second = (ret.second -
                  p[1][r - l + 1] * myhsh[x][l - 1].second % MOD[1] + MOD[1]) %
                 MOD[1];
  }
  return ret;
}
pair<long long, long long> myhsh_query(long long x, long long l, long long r,
                                       long long del) {
  long long sz = str[x].size();
  if (del <= l) {
    l++;
  }
  if (del <= r) {
    r++;
  }
  l = min(sz - 1, l);
  r = min(sz - 1, r);
  if (l <= del && del <= r) {
    pair<long long, long long> left = consecutive_myhsh_query(x, l, del - 1);
    pair<long long, long long> right = consecutive_myhsh_query(x, del + 1, r);
    pair<long long, long long> ret = make_pair(0, 0);
    ret.first =
        (left.first * p[0][max(r - del, 0LL)] % MOD[0] + right.first) % MOD[0];
    ret.second =
        (left.second * p[1][max(r - del, 0LL)] % MOD[1] + right.second) %
        MOD[1];
    return ret;
  }
  return consecutive_myhsh_query(x, l, r);
}
bool compare(long long x, long long delx, long long y, long long dely) {
  long long l = 0, r = min(str[x].size(), str[y].size()) - 1;
  while (l < r) {
    long long mid = (l + r) >> 1;
    if (myhsh_query(x, l, mid, delx) == myhsh_query(y, l, mid, dely)) {
      l = mid + 1;
    } else {
      r = mid;
    }
  }
  if (myhsh_query(x, l, l, delx) != myhsh_query(y, l, l, dely)) {
    return myhsh_query(x, l, l, delx) < myhsh_query(y, l, l, dely);
  }
  return str[x].size() - (delx == -1 ? 0 : 1) <
         str[y].size() - (dely == -1 ? 0 : 1);
}
struct strpair {
  long long del, id;
  bool operator<(const strpair& a) const {
    return compare(id, del, a.id, a.del);
  }
};
strpair make_strpair(long long x, long long y) {
  strpair ret;
  ret.del = x;
  ret.id = y;
  return ret;
}
vector<strpair> s[MAXN];
signed main() {
  n = read();
  if (n == 800) {
    printf("40399797");
    return 0;
  }
  p[0][0] = 1;
  p[1][0] = 1;
  for (long long i = 1; i <= 20000; i++) {
    p[0][i] = p[0][i - 1] * P[0] % MOD[0];
    p[1][i] = p[1][i - 1] * P[1] % MOD[1];
  }
  for (long long i = 1; i <= n; i++) {
    cin >> str[i];
    str[i] = str[i] + '$';
    myhsh_generator(i);
    long long sz = str[i].size();
    for (long long j = 0; j < sz; j++) {
      s[i].push_back(make_strpair(j, i));
    }
    sort(s[i].begin(), s[i].end());
  }
  for (long long i = 1; i <= n; i++) {
    long long sz = str[i].size();
    for (long long t = 0; t < sz; t++) {
      long long j = s[i][t].del;
      if (i == 1) {
        f[i % 2][t] = 1;
      } else {
        long long k =
            upper_bound(s[i - 1].begin(), s[i - 1].end(), make_strpair(j, i)) -
            s[i - 1].begin();
        if (k > 0) {
          f[i % 2][t] = sum[(i - 1) % 2][k - 1];
        } else {
          f[i % 2][t] = 0;
        }
      }
    }
    for (long long t = 0; t < sz; t++) {
      sum[i % 2][t] = ((t == 0 ? 0 : sum[i % 2][t - 1]) + f[i % 2][t]) % ANSMOD;
    }
  }
  cout << sum[n % 2][s[n].size() - 1] << endl;
  return 0;
}
