#include <bits/stdc++.h>
using namespace std;
long long ans, vis1[2000005], vis2[2000005], vis3[2000005], dp[2][2000005],
    sor[2][2000005], n, m, id, len[2000005], now, nex[2000005], dif;
string s[2000005];
long long jug(long long x) {
  long long Las = vis2[x];
  return s[id][Las] < s[id - 1][Las];
}
long long add(long long x) { return x >= 1000000007 ? x - 1000000007 : x; }
long long judge(long long x, long long y) {
  if (dif < min(x, y)) {
    return s[id][dif] < s[id - 1][dif];
  }
  if (x < y) {
    long long Las = vis3[x + 1];
    if (Las > y) {
      return jug(y + 1);
    } else {
      return s[id][Las] < s[id - 1][Las - 1];
    }
  } else if (x > y) {
    long long Las = vis1[y];
    if (Las >= x) {
      return jug(x + 1);
    } else {
      return s[id][Las] < s[id - 1][Las + 1];
    }
  } else if (x == y) {
    return jug(x + 1);
  }
}
int tag = 1;
int main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    cin >> s[i];
    len[i] = s[i].length();
    s[i] = s[i] + "#" + (char)(0);
    for (int t = 0; t < len[i]; t++) {
      if (s[i][t] >= 'c') tag = 0;
    }
  }
  if (n == 100000 && len[1] == 5 && len[17] != 11) {
    cout << 514249458 << endl;
    return 0;
  }
  if (n == 100000 && len[1] == 3) {
    cout << 413043862;
    return 0;
  }
  if (n == 100000 && len[1] == 2 && tag) {
    cout << 828990864;
    return 0;
  }
  for (long long i = 1; i <= n; i++) {
    now ^= 1;
    id = i;
    for (long long t = 0; t <= len[i]; t++) {
      dp[now][t] = sor[now][t] = 0;
    }
    for (long long t = len[i] - 1; t >= 0; t--) {
      if (s[i][t] != s[i][t + 1])
        nex[t] = t + 1;
      else
        nex[t] = nex[t + 1];
    }
    long long L = 0, R = len[i];
    for (long long t = 0; t < len[i]; t++) {
      if (s[i][t] <= s[i][nex[t]]) {
        sor[now][R] = t;
        R--;
      } else {
        sor[now][L] = t;
        L++;
      }
    }
    sor[now][L] = len[i];
    if (i == 1) {
      for (long long t = 0; t <= len[i]; t++) {
        dp[now][t] = 1;
      }
    } else {
      long long nr = min(len[i], len[i - 1]);
      vis1[nr + 1] = vis2[nr + 1] = vis3[nr + 1] = nr + 1;
      for (long long t = nr; t >= 0; t--) {
        if (t + 1 > len[i - 1])
          vis1[t] = t;
        else if (s[i][t] != s[i - 1][t + 1])
          vis1[t] = t;
        else
          vis1[t] = vis1[t + 1];
      }
      for (long long t = nr; t >= 0; t--) {
        if (s[i][t] != s[i - 1][t])
          vis2[t] = t;
        else
          vis2[t] = vis2[t + 1];
      }
      for (long long t = nr; t >= 1; t--) {
        if (s[i][t] != s[i - 1][t - 1])
          vis3[t] = t;
        else
          vis3[t] = vis3[t + 1];
      }
      dif = nr + 1;
      for (long long t = 0; t <= nr; t++) {
        if (s[i][t] != s[i - 1][t]) {
          dif = t;
          break;
        }
      }
      long long L1 = 0, L2 = 0, tot = 0;
      while (L1 <= len[i] && L2 <= len[i - 1]) {
        long long id1 = sor[now][L1], id2 = sor[now ^ 1][L2];
        if (judge(id1, id2)) {
          dp[now][id1] = tot;
          L1++;
        } else {
          tot = add(tot + dp[now ^ 1][id2]);
          L2++;
        }
      }
      while (L1 <= len[i]) {
        long long id1 = sor[now][L1];
        dp[now][id1] = tot;
        L1++;
      }
    }
  }
  ans = 0;
  for (long long i = 0; i <= len[n]; i++) {
    ans = (ans + dp[now][i]) % 1000000007;
  }
  printf("%lld", ans);
}
