#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
inline void accell() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
}
void say(string s) {
  cout << s << endl;
  return;
}
template <class T>
ostream& operator<<(ostream& out, const pair<int, int>& X) {
  out << X.first << ' ' << X.second << endl;
  return out;
}
template <class T>
ostream& operator<<(ostream& out, const vector<T>& X) {
  for (const auto& it : X) out << it << ' ';
  return out;
}
template <class T>
ostream& operator<<(ostream& out, const set<T>& X) {
  for (const auto& it : X) out << it << ' ';
  return out;
}
template <class T>
void dbg(const T& X) {
  cerr << "DEBUG: "
       << ": ";
  cerr << X << endl;
}
const int MOD1 = 1e9 + 7;
const int N = 1e6 + 1;
const int MOD2 = 998244353;
const int inf = 3e18;
const int mx = (1 << 19) - 1;
const int mod = 1e9 + 7;
const ull K = 147;
const int mod2 = mod * mod;
signed main() {
  accell();
  int n;
  cin >> n;
  vector<string> a(n);
  vector<vector<ull>> hsh(n);
  vector<ull> mult(N);
  mult[0] = 1;
  for (int i = 1; i < N; ++i) {
    mult[i] = mult[i - 1] * K;
  }
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<vector<pair<int, int>>> ids(n);
  for (int i = 0; i < n; ++i) {
    ids[i].resize((int)(a[i]).size() + 1);
    for (int j = 0; j < (int)(a[i]).size(); ++j) {
      ids[i][j] = {i, j};
    }
    ids[i].back() = {i, inf};
    hsh[i].resize((int)(a[i]).size() + 1);
    hsh[i][0] = 0;
    for (int j = 1; j <= (int)(a[i]).size(); ++j) {
      hsh[i][j] = hsh[i][j - 1] + (a[i][j - 1] - 'a' + 1) * mult[j];
    }
  }
  auto get_hsh = [&](int i, int j, int l, int r) {
    if (r >= j) {
      ull c = hsh[i][r + 2] - hsh[i][j + 1];
      ull d = hsh[i][j] * K;
      return c + d;
    } else {
      ull c = hsh[i][r + 1] * K;
      return c;
    }
  };
  auto get_symbol = [&](int i, int j, int k) {
    if (k == inf) {
      return 'A';
    } else if (k >= j) {
      return a[i][k + 1];
    } else {
      return a[i][k];
    }
  };
  auto comp = [&](int i, int j, int i1, int j1) {
    int l = 0;
    int len1 = (int)(a[i]).size() + (j == inf);
    int len2 = (int)(a[i1]).size() + (j1 == inf);
    int r = min(len1, len2);
    while (r - l > 1) {
      int m = (l + r) / 2;
      if (get_hsh(i, j, 0, m - 1) == get_hsh(i1, j1, 0, m - 1)) {
        l = m;
      } else {
        r = m;
      }
    }
    if (r == min(len1, len2)) {
      if (len1 == len2) {
        return i < i1;
      }
      return len1 < len2;
    }
    return get_symbol(i, j, r - 1) < get_symbol(i1, j1, r - 1);
  };
  auto cmp = [&](pair<int, int> a, pair<int, int> b) {
    bool c = comp(a.first, a.second, b.first, b.second);
    return c;
  };
  vector<vector<int>> dp(n);
  for (int i = 0; i < n; ++i) {
    dp[i].resize((int)(ids[i]).size());
    sort(ids[i].begin(), ids[i].end(), cmp);
  }
  dp[0].assign((int)(dp[0]).size(), 1);
  auto add = [&](int& x, int y) {
    x += y;
    if (x >= mod) x -= mod;
  };
  for (int i = 0; i + 1 < n; ++i) {
    int p1 = 0;
    int p2 = 0;
    int s = 0;
    while (p1 < (int)(ids[i]).size() || p2 < (int)(ids[i + 1]).size()) {
      if (p2 == (int)(ids[i + 1]).size()) {
        add(s, dp[i][min(ids[i][p1].second, (int)(a[i]).size())]);
        ++p1;
      } else if (p1 == (int)(ids[i]).size()) {
        add(dp[i + 1][min(ids[i + 1][p2].second, (int)(a[i + 1]).size())], s);
        ++p2;
      } else {
        auto x = ids[i][p1];
        auto y = ids[i + 1][p2];
        if (cmp(x, y)) {
          add(s, dp[i][min(x.second, (int)(a[i]).size())]);
          p1++;
        } else {
          add(dp[i + 1][min(y.second, (int)(a[i + 1]).size())], s);
          p2++;
        }
      }
    }
  }
  cout << accumulate(dp[n - 1].begin(), dp[n - 1].end(), 0LL) % mod << '\n';
  return 0;
}
