#include <bits/stdc++.h>
using namespace std;
template <class T>
using v2d = vector<vector<T>>;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
const int maxN = 1e3 + 10;
const int maxS = 2e4 + 10;
const long long mod = 1e9 + 7;
const pair<long long, long long> modHash = {1000000007, 1000000009};
const long long base = 31;
int n;
string s[maxN];
vector<pair<long long, long long>> h[maxN];
pair<long long, long long> pw[maxS];
vector<int> d[maxN];
vector<long long> dp[maxN];
void init() {
  pw[0] = {1, 1};
  for (int i = 1; i <= (int)(2e4); ++i) {
    pw[i].first = pw[i - 1].first * base % modHash.first;
    pw[i].second = pw[i - 1].second * base % modHash.second;
  }
}
pair<long long, long long> calHash(int i, int j, int k) {
  if (k < j) {
    return h[i][k];
  }
  pair<long long, long long> ans;
  if (j > 0) {
    ans.first = (h[i][k + 1].first +
                 (h[i][j - 1].first - h[i][j].first) * pw[k + 1 - j].first %
                     modHash.first +
                 modHash.first) %
                modHash.first;
    ans.second = (h[i][k + 1].second +
                  (h[i][j - 1].second - h[i][j].second) * pw[k + 1 - j].second %
                      modHash.second +
                  modHash.second) %
                 modHash.second;
  } else {
    ans.first =
        (h[i][k + 1].first -
         h[i][j].first * pw[k + 1 - j].first % modHash.first + modHash.first) %
        modHash.first;
    ans.second = (h[i][k + 1].second -
                  h[i][j].second * pw[k + 1 - j].second % modHash.second +
                  modHash.second) %
                 modHash.second;
  }
  return ans;
}
bool compString(int i1, int j1, int i2, int j2) {
  int len1 = (int)s[i1].size() - (j1 != (int)s[i1].size()),
      len2 = (int)s[i2].size() - (j2 != (int)s[i2].size());
  int l = 0, r = min(len1, len2) + 1;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (calHash(i1, j1, mid - 1) == calHash(i2, j2, mid - 1)) {
      l = mid;
    } else {
      r = mid;
    }
  }
  if (l == len1 || l == len2) {
    return (len1 < len2);
  }
  return (s[i1][l + (l >= j1)] < s[i2][l + (l >= j2)]);
}
void solve() {
  cin >> n;
  for (int i = 1; i <= (int)(n); ++i) {
    cin >> s[i];
  }
  for (int i = 1; i <= (int)(n); ++i) {
    h[i].resize(s[i].size());
    pair<long long, long long> pv = {0, 0};
    for (int j = 0; j < (int)(s[i].size()); ++j) {
      h[i][j].first =
          (pv.first * base % modHash.first + s[i][j] - 'a' + 1) % modHash.first;
      h[i][j].second = (pv.second * base % modHash.second + s[i][j] - 'a' + 1) %
                       modHash.second;
      pv = h[i][j];
    }
  }
  for (int i = 1; i <= (int)(n); ++i) {
    for (int j = (int)(0); j <= (int)(s[i].size()); ++j) {
      d[i].emplace_back(j);
    }
    sort((d[i]).begin(), (d[i]).end(), [&](int x, int y) -> bool {
      if (x == y && x == (int)s[i].size()) {
        return 0;
      }
      int l = 0, r = s[i].size();
      while (r - l > 1) {
        int mid = (l + r) / 2;
        if (calHash(i, x, mid - 1) == calHash(i, y, mid - 1)) {
          l = mid;
        } else {
          r = mid;
        }
      }
      if (l == (int)s[i].size() - 1) {
        return x < y;
      }
      return s[i][l + (l >= x)] < s[i][l + (l >= y)];
    });
  }
  for (int i = 1; i <= (int)(n); ++i) {
    dp[i].resize(d[i].size());
  }
  for (int j = 0; j < (int)(d[1].size()); ++j) {
    dp[1][j] = j + 1;
  }
  for (int i = (int)(2); i <= (int)(n); ++i) {
    for (int j = 0; j < (int)(d[i].size()); ++j) {
      int l = -1, r = (int)d[i - 1].size();
      while (r - l > 1) {
        int mid = (l + r) / 2;
        if (!compString(i, d[i][j], i - 1, d[i - 1][mid])) {
          l = mid;
        } else {
          r = mid;
        }
      }
      if (l >= 0) {
        dp[i][j] = dp[i - 1][l];
      }
    }
    for (int j = 1; j <= (int)((int)d[i].size() - 1); ++j) {
      dp[i][j] += dp[i][j - 1];
      if (dp[i][j] >= mod) {
        dp[i][j] -= mod;
      }
    }
  }
  cout << dp[n].back();
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  init();
  int T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
