#include <bits/stdc++.h>
using namespace std;
template <class T>
using v2d = vector<vector<T>>;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
const int maxN = 1e5 + 10;
const int maxS = 1e6 + 10;
const long long mod = 1e9 + 7;
const long long modHash = 1e9 + 7;
const long long base = 31;
using ull = uint64_t;
int n;
string s[maxN];
vector<pair<long long, ull>> h[maxN], diff[maxN];
pair<long long, ull> pw[maxS];
vector<int> d[maxN], lcp[maxN];
vector<long long> dp[maxN];
void init() {
  pw[0] = {1, 1};
  for (int i = 1; i <= (int)(1e6); ++i) {
    pw[i].first = pw[i - 1].first * base % modHash;
    pw[i].second = pw[i - 1].second * (ull)base;
  }
}
pair<long long, ull> calPrefixHash(int i, int j, int k) {
  if (k < j) {
    return h[i][k];
  }
  pair<long long, ull> ans;
  ans.first =
      (h[i][k + 1].first + diff[i][j].first * pw[k + 1 - j].first) % modHash;
  ans.second = h[i][k + 1].second + diff[i][j].second * pw[k + 1 - j].second;
  return ans;
}
pair<long long, ull> calHash(int i, int l, int r) {
  pair<long long, ull> ans;
  if (l >= 1) {
    ans.first = (h[i][r].first - h[i][l - 1].first * pw[r - l + 1].first +
                 modHash * modHash) %
                modHash;
    ans.second = h[i][r].second - h[i][l - 1].second * pw[r - l + 1].second;
  } else {
    ans = h[i][r];
  }
  return ans;
}
bool compString(int i1, int j1, int i2, int j2) {
  int len1 = (int)s[i1].size() - (j1 != (int)s[i1].size()),
      len2 = (int)s[i2].size() - (j2 != (int)s[i2].size());
  int l = 0, r = min(len1, len2) + 1;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (calPrefixHash(i1, j1, mid - 1) == calPrefixHash(i2, j2, mid - 1)) {
      l = mid;
    } else {
      r = mid;
    }
  }
  if (l == len1 || l == len2) {
    return (len1 < len2);
  }
  return (s[i1][l + (l >= j1)] < s[i2][l + (l >= j2)]);
}
void solve() {
  cin >> n;
  for (int i = 1; i <= (int)(n); ++i) {
    cin >> s[i];
  }
  for (int i = 1; i <= (int)(n); ++i) {
    h[i].resize(s[i].size());
    diff[i].resize(s[i].size());
    pair<long long, ull> pv = {0, 0};
    for (int j = 0; j < (int)(s[i].size()); ++j) {
      h[i][j].first = (pv.first * base % modHash + s[i][j] - 'a' + 1) % modHash;
      h[i][j].second = pv.second * base + (ull)(s[i][j] - 'a' + 1);
      diff[i][j].first = (pv.first - h[i][j].first + modHash) % modHash;
      diff[i][j].second = pv.second - h[i][j].second;
      pv = h[i][j];
    }
  }
  for (int i = 1; i <= (int)(n); ++i) {
    lcp[i].resize((int)s[i].size());
    for (int j = 0; j < (int)((int)s[i].size() - 1); ++j) {
      int l = 0, r = (int)s[i].size() - j;
      while (r - l > 1) {
        int mid = (l + r) / 2;
        if (calHash(i, j, j + mid - 1) == calHash(i, j + 1, j + mid)) {
          l = mid;
        } else {
          r = mid;
        }
      }
      lcp[i][j] = l;
    }
    lcp[i][(int)s[i].size() - 1] = 0;
  }
  for (int i = 1; i <= (int)(n); ++i) {
    for (int j = (int)(0); j <= (int)(s[i].size()); ++j) {
      d[i].emplace_back(j);
    }
    sort((d[i]).begin(), (d[i]).end(), [&](int x, int y) -> bool {
      if (x == y) {
        return 0;
      }
      if (x < y) {
        if (x == (int)s[i].size() - 1) {
          return 1;
        }
        int len = min(lcp[i][x], y - x);
        if (len == y - x) {
          return 0;
        }
        return s[i][x + len + 1] < s[i][x + len];
      }
      if (y == (int)s[i].size() - 1) {
        return 0;
      }
      int len = min(lcp[i][y], x - y);
      if (len == x - y) {
        return 0;
      }
      return s[i][y + len] < s[i][y + len + 1];
    });
  }
  for (int i = 1; i <= (int)(n); ++i) {
    dp[i].resize(d[i].size());
  }
  for (int j = 0; j < (int)(d[1].size()); ++j) {
    dp[1][j] = j + 1;
  }
  for (int i = (int)(2); i <= (int)(n); ++i) {
    int idx = -1;
    for (int j = 0; j < (int)(d[i].size()); ++j) {
      while (idx + 1 < (int)d[i - 1].size() &&
             !compString(i, d[i][j], i - 1, d[i - 1][idx + 1])) {
        idx++;
      }
      if (idx >= 0) {
        dp[i][j] = dp[i - 1][idx];
      }
      if (j >= 1) {
        dp[i][j] += dp[i][j - 1];
        if (dp[i][j] >= mod) {
          dp[i][j] -= mod;
        }
      }
    }
  }
  cout << dp[n].back();
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  init();
  int T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
