#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 7, INF = 0x3f3f3f3f, MOD = 1e9 + 7;
const long long LNF = 0x3f3f3f3f3f3f3f3f;
const int mod[4] = {998244353, 19260817, 1000000007, 1019260817},
          bas[4] = {2333, 1926, 23333, 114514};
const int D = 1;
struct Has {
  int has[N][D];
  static int w[N][D];
  static void init() {
    for (int i = 0; i < D; ++i) {
      w[0][i] = 1;
    }
    for (int i = 1; i < N; ++i) {
      for (int j = 0; j < D; ++j) {
        w[i][j] = 1LL * w[i - 1][j] * bas[j] % mod[j];
      }
    }
  }
  void build(int *s, int len) {
    for (int i = 0; i < D; ++i) {
      has[0][i] = 0;
    }
    for (int i = 1; i <= len; ++i) {
      for (int j = 0; j < D; ++j) {
        has[i][j] =
            (1LL * has[i - 1][j] * bas[j] + (s[i - 1] - 'a' + 1)) % mod[j];
      }
    }
  }
  int get(int l, int r) {
    ++l;
    ++r;
    return (has[r][0] - 1LL * has[l - 1][0] * w[r - l + 1][0] % mod[0] +
            mod[0]) %
           mod[0];
  }
} has;
int Has::w[N][D] = {};
int s[N];
string str[N];
int st[N], nx[N];
vector<int> sorted[N], Dp[N];
inline int lcp(int x, int y, int up) {
  int l = 0, r = up + 1, mid;
  while (r > l) {
    mid = r + l >> 1;
    if (has.get(x, x + mid - 1) == has.get(y, y + mid - 1)) {
      l = mid + 1;
    } else {
      r = mid;
    }
  }
  return r - 1;
}
inline void ssort(int id) {
  string &ts = str[id];
  sorted[id].resize(str[id].length() + 1);
  int l = 0, r = str[id].length();
  nx[ts.length() - 1] = ts.length() - 1;
  for (int i = ts.length() - 2; i >= 0; --i) {
    nx[i] = ts[i] == ts[i + 1] ? nx[i + 1] : i + 1;
  }
  for (int i = 0; i < ts.length(); ++i) {
    if (ts[i] < ts[nx[i]]) {
      sorted[id][r--] = i;
    } else {
      sorted[id][l++] = i;
    }
  }
  sorted[id][r--] = ts.length();
}
inline int cmp(int x, int xp, int y, int yp) {
  int sx = 0, sy = 0;
  while (1) {
    if (sx == xp && sx < str[x].length()) {
      sx++;
    }
    if (sy == yp && sy < str[y].length()) {
      sy++;
    }
    int lx = sx < xp ? xp - sx : str[x].length() - sx;
    int ly = sy < yp ? yp - sy : str[y].length() - sy;
    if (!lx || !ly) {
      return lx <= ly;
    }
    int l = min(lx, ly);
    int mt = lcp(st[x] + sx, st[y] + sy, l);
    if (mt < l) {
      return str[x][sx + mt] < str[y][sy + mt];
    }
    sx += l;
    sy += l;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  Has::init();
  cin >> n;
  int len = 0;
  for (int i = 0; i < n; ++i) {
    cin >> str[i];
    st[i] = len;
    for (int j = 0; j < str[i].length(); ++j) {
      s[len++] = str[i][j];
    }
    s[len++] = 130 + i;
  }
  has.build(s, len);
  for (int i = 0; i < n; ++i) {
    ssort(i);
  }
  Dp[0] = vector<int>(str[0].length() + 1, 1);
  for (int i = 1; i < n; ++i) {
    Dp[i] = vector<int>(str[i].length() + 1, 0);
    int p = 0, sum = 0;
    for (int j = 0; j < sorted[i].size(); ++j) {
      while (p < sorted[i - 1].size() &&
             cmp(i - 1, sorted[i - 1][p], i, sorted[i][j])) {
        sum += Dp[i - 1][sorted[i - 1][p++]];
        if (sum >= MOD) {
          sum -= MOD;
        }
      }
      Dp[i][sorted[i][j]] = sum;
    }
  }
  int ans = 0;
  for (int x : Dp[n - 1]) {
    ans += x;
    if (ans >= MOD) {
      ans -= MOD;
    }
  }
  cout << ans << endl;
}
