#include <bits/stdc++.h>
using namespace std;
using namespace std;
const int maxm = 1000000 + 10;
const int maxn = 1000 + 10;
const int hnum = 2;
const long long hsv[3] = {23, 67, 81};
const long long mod = 1000000000 + 7;
long long dp[2][maxm];
int n;
string s[maxn];
int Len[maxn];
vector<long long> H[hnum][maxn];
long long po[hnum][maxm];
vector<long long> Rank[maxn];
inline long long getval(int i, int id, int st, int l) {
  if (l == 0) return 0;
  long long ans = H[i][id][st] - (H[i][id][st + l] * po[i][l] % mod);
  ans %= mod;
  ans += mod;
  ans %= mod;
  return ans;
}
inline void init() {
  for (auto i = (0); i < (hnum); ++i) {
    for (auto j = (0); j < (maxm); ++j) {
      if (j == 0)
        po[i][j] = 1;
      else
        po[i][j] = po[i][j - 1] * hsv[i] % mod;
    }
  }
}
inline void clear(int t, int i) {
  for (int i = 0; i <= Len[i]; ++i) dp[t][i] = 0;
}
inline long long getleak(int o, int i, int p1, int len) {
  long long v1 = 0;
  if (len <= p1)
    v1 = getval(o, i, 0, len);
  else {
    v1 = getval(o, i, 0, p1);
    v1 = getval(o, i, p1 + 1, len - p1) * po[o][p1] % mod + v1;
    v1 %= mod;
  }
  return v1;
}
inline int judge(int i, int p1, int p2) {
  int l, r, l1, l2;
  l1 = Len[i], l2 = Len[i - 1];
  l = 0;
  if (p1 != l1) l1--;
  if (p2 != l2) l2--;
  auto check = [&](const int len) {
    for (auto o = (0); o < (hnum); ++o) {
      if ((len > l1 || len > l2) ||
          getleak(o, i, p1, len) != getleak(o, i - 1, p2, len))
        return false;
    }
    return true;
  };
  r = min(l1, l2);
  while (l < r) {
    int mid = l + (r - l + 1) / 2;
    if (check(mid))
      l = mid;
    else
      r = mid - 1;
  }
  char c1, c2;
  if (l == min(l1, l2)) {
    return l1 >= l2;
  }
  if (p1 > l)
    c1 = s[i][l];
  else {
    if (l + 1 < Len[i])
      c1 = s[i][l + 1];
    else
      c1 = 0;
  }
  if (p2 > l)
    c2 = s[i - 1][l];
  else {
    if (l + 1 < Len[i - 1])
      c2 = s[i - 1][l + 1];
    else
      c2 = 0;
  }
  assert(c1 != c2);
  return c1 > c2;
}
inline int judge(int i, int j, int p1, int p2) {
  int l, r, l1, l2;
  l1 = Len[i], l2 = Len[j];
  l = 0;
  if (p1 != l1) l1--;
  if (p2 != l2) l2--;
  auto check = [&](const int len) {
    for (auto o = (0); o < (hnum); ++o) {
      if ((len > l1 || len > l2) ||
          getleak(o, i, p1, len) != getleak(o, j, p2, len))
        return false;
    }
    return true;
  };
  r = min(l1, l2);
  while (l < r) {
    int mid = l + (r - l + 1) / 2;
    if (check(mid))
      l = mid;
    else
      r = mid - 1;
  }
  char c1, c2;
  if (l == min(l1, l2)) {
    return l1 >= l2;
  }
  if (p1 > l)
    c1 = s[i][l];
  else {
    if (l + 1 < Len[i])
      c1 = s[i][l + 1];
    else
      c1 = 0;
  }
  if (p2 > l)
    c2 = s[j][l];
  else {
    if (l + 1 < Len[j])
      c2 = s[j][l + 1];
    else
      c2 = 0;
  }
  assert(c1 != c2);
  return c1 > c2;
}
inline void solve() {
  int t = 0;
  for (auto i = (0); i <= (Len[0]); ++i) dp[t][i] = 1;
  for (auto i = (1); i < (n); ++i) {
    int k = 0;
    long long sum = 0;
    for (int j = 0; j <= Len[i]; ++j) {
      int x = Rank[i][j];
      while (k <= Len[i - 1] && judge(i, i - 1, x, Rank[i - 1][k])) {
        sum += dp[t][Rank[i - 1][k]];
        k++;
        if (sum >= mod) sum -= mod;
      }
      dp[t ^ 1][x] = sum;
    }
    t ^= 1;
  }
  long long ans = 0;
  for (auto i = (0); i <= (Len[n - 1]); ++i) {
    ans = ans + dp[t][i];
    if (ans >= mod) ans -= mod;
  }
  printf("%lld\n", ans);
}
int main(void) {
  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);
  ;
  cin >> n;
  init();
  for (auto i = (0); i < (n); ++i) cin >> s[i], Len[i] = s[i].length();
  for (auto i = (0); i < (n); ++i) {
    for (auto k = (0); k < (hnum); ++k) {
      H[k][i] = vector<long long>(Len[i] + 1, 0);
      H[k][i][Len[i]] = 0;
      for (auto j = (Len[i] - 1); j >= (0); --j) {
        H[k][i][j] = H[k][i][j + 1] * hsv[k] % mod;
        H[k][i][j] += (s[i][j] - 'a' + 1);
        H[k][i][j] %= mod;
      }
    }
  }
  for (auto i = (0); i < (n); ++i) {
    Rank[i] = vector<long long>(Len[i] + 1);
    for (auto j = (0); j <= (Len[i]); ++j) Rank[i][j] = j;
    sort((Rank[i]).begin(), (Rank[i]).end(), [&](const int& x, const int& y) {
      if (judge(i, i, x, y)) return false;
      return true;
    });
  }
  solve();
  return 0;
}
