#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream &operator<<(ostream &str, vector<T> &a) {
  for (auto &i : a) {
    str << i << " ";
  }
  return str;
}
template <class T>
istream &operator>>(istream &str, vector<T> &a) {
  for (auto &i : a) {
    str >> i;
  }
  return str;
}
template <class T>
ostream &operator<<(ostream &str, pair<T, T> &a) {
  str << a.first << " " << a.second;
  return str;
}
template <class T>
istream &operator>>(istream &str, pair<T, T> &a) {
  str >> a.first >> a.second;
  return str;
}
void solve();
signed main() {
  srand(time(0));
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.precision(6);
  solve();
  return 0;
}
const long long MOD = 1e9 + 7, MAXN = 1e6 + 10, INF = 1e18 + 10, BASE = 31;
long long n;
vector<vector<long long>> h;
vector<string> s;
vector<long long> p(MAXN);
char get_ch(long long i, long long id, long long cnt) {
  if (cnt < id) {
    return s[i][cnt];
  } else {
    cnt++;
    if (cnt >= (long long)((s[i]).size())) {
      return (char)('a' - 1 - ('a' - 2));
    } else {
      return s[i][cnt];
    }
  }
}
long long get_hash(long long i, long long id, long long len) {
  if (len < id + 1) {
    return h[i][len - 1];
  } else {
    if (id == 0) {
      return (h[i][len] - (long long)s[i][0] * p[len] % MOD + MOD * MOD) % MOD;
    } else {
      long long h1 = h[i][id - 1];
      long long h2 = (h[i][len] - s[i][id] * p[len - id] % MOD + MOD * MOD -
                      ((BASE - 1) * h1 % MOD) * p[len - id] % MOD) %
                     MOD;
      return h2;
    }
  }
}
bool smaller_or_equal(long long i1, long long id1, long long i2,
                      long long id2) {
  long long len = min((long long)((h[i1]).size()), (long long)((h[i2]).size()));
  long long l = -1, r = len;
  while (r - l > 1) {
    long long mid = (r + l) / 2;
    long long h1 = get_hash(i1, id1, mid + 1), h2 = get_hash(i2, id2, mid + 1);
    if (h1 == h2) {
      l = mid;
    } else {
      r = mid;
    }
  }
  if (l == -1) {
    return get_ch(i1, id1, 0) <= get_ch(i2, id2, 0);
  }
  if (l == len - 1) {
    return (long long)((h[i1]).size()) <= (long long)((h[i2]).size());
  } else {
    return get_ch(i1, id1, l + 1) <= get_ch(i2, id2, l + 1);
  }
}
void solve() {
  p[0] = 1;
  for (long long i = 1; i < MAXN; ++i) {
    p[i] = p[i - 1] * BASE % MOD;
  }
  cin >> n;
  h.resize(n + 1);
  s.resize(n + 1);
  s[0].push_back('a' - 1);
  vector<vector<long long>> dp(n + 1);
  for (long long i = 1; i <= n; ++i) {
    cin >> s[i];
    s[i].push_back('a' - 1);
    for (long long j = 0; j < (long long)((s[i]).size()); ++j) {
      s[i][j] -= ('a' - 2);
    }
    dp[i].resize((long long)((s[i]).size()));
    h[i].resize((long long)((s[i]).size()));
    h[i][0] = s[i][0];
    for (long long j = 1; j < (long long)((h[i]).size()); ++j) {
      h[i][j] = (h[i][j - 1] * BASE + s[i][j]) % MOD;
    }
  }
  dp[0].push_back(1);
  h[0].push_back(s[0][0]);
  vector<vector<long long>> id(n + 1);
  for (long long i = 1; i <= n; ++i) {
    vector<long long> nxt((long long)((s[i]).size()));
    long long ind = (long long)((s[i]).size()) - 1;
    long long j = (long long)((s[i]).size()) - 2;
    while (j >= 0) {
      char tmp = s[i][j];
      while (j >= 0 && s[i][j] == tmp) {
        nxt[j] = ind;
        j--;
      }
      ind = j + 1;
    }
    vector<long long> res((long long)((s[i]).size()) - 1);
    long long L = 0, R = (long long)((res).size()) - 1;
    for (long long j = 0; j < (long long)((s[i]).size()) - 1; ++j) {
      if (s[i][j] < s[i][nxt[j]]) {
        res[R--] = j;
      } else {
        res[L++] = j;
      }
    }
    if (res.back() == (long long)((res).size()) - 1) {
      res.push_back((long long)((res).size()));
    } else {
      for (long long j = 0; j < (long long)((res).size()); ++j) {
        if (res[j] == (long long)((res).size()) - 1) {
          res.insert(res.begin() + j + 1, (long long)((res).size()));
          break;
        }
      }
    }
    id[i] = res;
  }
  id[0].push_back(0);
  for (long long i = 1; i <= n; ++i) {
    long long sum = 0;
    long long j1 = 0;
    for (long long j2 = 0; j2 < (long long)((id[i]).size()); ++j2) {
      while (j1 < (long long)((id[i - 1]).size()) &&
             smaller_or_equal(i - 1, id[i - 1][j1], i, id[i][j2])) {
        sum = (dp[i - 1][id[i - 1][j1]] + sum) % MOD;
        j1++;
      }
      dp[i][id[i][j2]] = sum;
    }
  }
  long long ans = 0;
  for (long long j = 0; j < (long long)((dp[n]).size()); ++j) {
    ans = (ans + dp[n][j]) % MOD;
  }
  cout << ans << '\n';
}
