#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 7, INF = 0x3f3f3f3f, mod = 1e9 + 7;
const long long LNF = 0x3f3f3f3f3f3f3f3f;
int has[N], w[N];
int bas = 233333;
void init() {
  w[0] = 1;
  for (int i = 1; i < N; ++i) {
    w[i] = 1LL * w[i - 1] * bas % mod;
  }
}
void build(int *s, int len) {
  has[0] = 0;
  for (int i = 1; i <= len; ++i) {
    has[i] = (1LL * has[i - 1] * bas + (s[i - 1] - 'a' + 1)) % mod;
  }
}
inline int get(int l, int r) {
  ++l;
  ++r;
  return (has[r] - 1LL * has[l - 1] * w[r - l + 1] % mod + mod) % mod;
}
int s[N];
string str[N];
int st[N], nx[N];
vector<int> sorted[N];
int Dp[2][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 (get(x, x + mid - 1) == 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);
  init();
  int n;
  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;
  }
  build(s, len);
  for (int i = 0; i < n; ++i) {
    ssort(i);
  }
  int cur = 0;
  for (int i = 0; i <= str[0].length(); ++i) {
    Dp[cur][i] = 1;
  }
  for (int i = 1; i < n; ++i) {
    cur ^= 1;
    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[cur ^ 1][sorted[i - 1][p++]];
        if (sum >= mod) {
          sum -= mod;
        }
      }
      Dp[cur][sorted[i][j]] = sum;
    }
  }
  int ans = 0;
  for (int i = 0; i <= str[n - 1].length(); ++i) {
    ans += Dp[cur][i];
    if (ans >= mod) {
      ans -= mod;
    }
  }
  cout << ans << endl;
}
