#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
long long sub(long long a, long long b, long long MOD1 = MOD) {
  long long r = a - b;
  if (r < 0) r += MOD1;
  return r;
}
long long sum(long long a, long long b, long long MOD1 = MOD) {
  long long r = a + b;
  if (r >= MOD1) r -= MOD1;
  return r;
}
struct Hash {
  __int128 MODD = 212345678987654321LL, P = 1777771, PI = 106955741089659571LL;
  vector<__int128> h, pi;
  Hash() {}
  Hash(string& s) {
    assert((P * PI) % MODD == 1);
    h.resize(s.size() + 1);
    pi.resize(s.size() + 1);
    h[0] = 0;
    pi[0] = 1;
    __int128 p = 1;
    for (int i = 1, ThxDem = s.size() + 1; i < ThxDem; ++i) {
      h[i] = (h[i - 1] + p * s[i - 1]) % MODD;
      pi[i] = (pi[i - 1] * PI) % MODD;
      p = (p * P) % MODD;
    }
  }
  long long get(int s, int e) {
    return (((h[e] - h[s] + MODD) % MODD) * pi[s]) % MODD;
  }
  long long getval(int k, int p) {
    if (p >= k) return h[k];
    __int128 v1 = h[p];
    __int128 v2 = sub(h[k + 1], h[p + 1], MODD);
    v2 = v2 * PI % MODD;
    return sum(v1, v2, MODD);
  }
};
const int MAXN = 1e5 + 10;
Hash hs[MAXN];
string s[MAXN];
bool cmp(pair<int, int> x, pair<int, int> y) {
  int top = min(int(s[x.first].size()), int(s[y.first].size())) - 1;
  int l = 1, r = top;
  while (l <= r) {
    int m = (l + r) / 2;
    long long v1 = hs[x.first].getval(m, x.second);
    long long v2 = hs[y.first].getval(m, y.second);
    if (v1 == v2)
      l = m + 1;
    else
      r = m - 1;
  }
  if (l > top) {
    int v1 = int(s[x.first].size()), v2 = int(s[y.first].size());
    if (x.second != v1 - 1) v1--;
    if (y.second != v2 - 1) v2--;
    return v1 < v2;
  }
  int id1 = l - 1, id2 = l - 1;
  if (x.second < l) id1++;
  if (y.second < l) id2++;
  assert(id1 >= 0 && id1 < int(s[x.first].size()));
  assert(id2 >= 0 && id2 < int(s[y.first].size()));
  return s[x.first][id1] < s[y.first][id2];
}
vector<pair<int, int> > g[MAXN];
vector<int> ac[MAXN];
int mem[110][110];
int n;
int solve(int pos, int pre) {
  if (pos == n) return 1;
  int& r = mem[pos][pre];
  if (r >= 0) return r;
  r = 0;
  for (int j = 0, ThxDem = int(s[pos].size()); j < ThxDem; ++j) {
    string me = s[pos];
    me.erase(me.begin() + j);
    if (me.back() < 'a') me.pop_back();
    if (!pos)
      r += solve(pos + 1, j);
    else {
      string he = s[pos - 1];
      he.erase(he.begin() + pre);
      if (he.back() < 'a') he.pop_back();
      if (he <= me) r += solve(pos + 1, j);
    }
  }
  return r;
}
void order(int wh, vector<pair<int, int> >& ans) {
  int lst = -1, n = int(s[wh].size());
  vector<int> nex(n, -1);
  for (int i = n - 2; i >= 0; i--) {
    if (s[wh][i] != s[wh][i + 1])
      nex[i] = i + 1;
    else
      nex[i] = nex[i + 1];
  }
  ans.assign(n, {wh, 0});
  int le = 0, ri = n - 1;
  for (int i = 0, ThxDem = n - 1; i < ThxDem; ++i) {
    if (s[wh][i] < s[wh][nex[i]])
      ans[ri].second = i, ri--;
    else
      ans[le].second = i, le++;
  }
  ans[le].second = n - 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  memset(mem, -1, sizeof(mem));
  cin >> n;
  for (int i = 0, ThxDem = n; i < ThxDem; ++i) {
    cin >> s[i];
    s[i].push_back('a' - 1);
    hs[i] = Hash(s[i]);
    order(i, g[i]);
    ac[i].assign(int(s[i].size()), 0);
  }
  for (int j = 0, ThxDem = int(s[0].size()); j < ThxDem; ++j) ac[0][j] = j + 1;
  for (int i = 1, ThxDem = n; i < ThxDem; ++i) {
    int r = 0;
    for (int j = 0, ThxDem = int(s[i].size()); j < ThxDem; ++j) {
      while (r < int(s[i - 1].size()) && !cmp(g[i][j], g[i - 1][r])) r++;
      int id = r - 1;
      if (id >= 0) ac[i][j] = ac[i - 1][id];
      if (j) ac[i][j] = sum(ac[i][j], ac[i][j - 1]);
    }
  }
  int ans = ac[n - 1][int(s[n - 1].size()) - 1];
  cout << ans << "\n";
}
