#include <bits/stdc++.h>
using namespace std;
struct num {
  static const int MA = 1e9 + 7, MB = 1e9 + 9;
  int a, b;
  num() {}
  num(int x) : a(x), b(x) {}
  num(int a, int b) : a(a), b(b) {}
  num operator+(const num& x) const {
    return num((a + x.a) % MA, (b + x.b) % MB);
  }
  num operator-(const num& x) const {
    return num((a + MA - x.a) % MA, (b + MB - x.b) % MB);
  }
  num operator*(int x) const {
    return num(((long long)a * x) % MA, ((long long)b * x) % MB);
  }
  num operator*(const num& x) const {
    return num(((long long)a * x.a) % MA, ((long long)b * x.b) % MB);
  }
  bool operator==(const num& x) const { return a == x.a && b == x.b; }
};
const int MODP = 701;
struct StringOps {
  StringOps() {}
  StringOps(const string& s) : s(s) {
    n = s.length();
    deg.resize(n + 1);
    hashes.resize(n);
    deg[0] = num(1);
    for (int i = 1; i <= n; ++i) {
      deg[i] = deg[i - 1] * num(MODP);
    }
    num curhash = num(0);
    for (int i = 0; i < n; ++i) {
      curhash = curhash * num(MODP) + num(s[i]);
      hashes[i] = curhash;
    }
  }
  char get(int idx) { return s[idx]; }
  num get_hash(int l, int r) {
    num cur(0);
    if (l > 0) {
      cur = hashes[l - 1];
    }
    return hashes[r] - cur * deg[r - l + 1];
  }
  int string_lcp(int l, int r) {
    int cleft = 1, cright = min(n - r, n - l);
    int res = 0;
    while (cleft <= cright) {
      int key = (cleft + cright) / 2;
      if (get_hash(l, l + key - 1) == get_hash(r, r + key - 1)) {
        res = key;
        cleft = key + 1;
      } else {
        cright = key - 1;
      }
    }
    return res;
  }
  bool substring_cmp(int l1, int r1, int l2, int r2) {
    int lcp = string_lcp(l1, l2);
    int len1 = r1 - l1 + 1, len2 = r2 - l2 + 1;
    if (lcp >= len1 && lcp >= len2) {
      return len1 < len2;
    }
    if (lcp >= len1) {
      return true;
    }
    if (lcp >= len2) {
      return false;
    }
    return s[l1 + lcp] < s[l2 + lcp];
  }
  vector<num> hashes;
  vector<num> deg;
  string s;
  int n;
};
const int maxN = 21000;
const int MOD = 1e9 + 7;
int len1, len2;
int u, v;
StringOps sops;
int get_nlength(const pair<int, int>& a) {
  if (a.first == u) {
    if (a.second != len1) {
      return len1 - 1;
    } else {
      return len1;
    }
  }
  if (a.second != len2) {
    return len2 - 1;
  } else {
    return len2;
  }
}
void fill_segs(int& l1, int& r1, int& l2, int& r2, const pair<int, int>& a) {
  if (a.first == u) {
    l2 = r2 = -1;
    if (a.second == 0) {
      l1 = 1, r1 = len1 - 1;
    } else if (a.second >= len1 - 1) {
      l1 = 0, r1 = a.second - 1;
    } else {
      l1 = 0, r1 = a.second - 1;
      l2 = a.second + 1, r2 = len1 - 1;
    }
    return;
  }
  l2 = r2 = -1;
  if (a.second == 0) {
    l1 = 1, r1 = len2 - 1;
  } else if (a.second >= len2 - 1) {
    l1 = 0, r1 = a.second - 1;
  } else {
    l1 = 0, r1 = a.second - 1;
    l2 = a.second + 1, r2 = len2 - 1;
  }
  l1 += len1, r1 += len1;
  if (l2 != -1) {
    l2 += len1, r2 += len1;
  }
}
int cmp2(vector<pair<int, int>>& a, vector<pair<int, int>>& b) {
  if (a.size() == 0 && b.size() > 0) {
    return -1;
  }
  if (a.size() == 0 && b.size() == 0) {
    return 0;
  }
  if (b.size() == 0 && a.size() > 0) {
    return 1;
  }
  if (a.size() == 1 && b.size() == 1 && a[0] == b[0]) {
    return 0;
  }
  if (a.size() == 2 && b.size() == 2 && a[0] == b[0] && a[1] == b[1]) {
    return 0;
  }
  if (sops.get(a[0].first) != sops.get(b[0].first)) {
    int cmp1 =
        sops.substring_cmp(a[0].first, a[0].first, b[0].first, b[0].first);
    int cmp2 =
        sops.substring_cmp(b[0].first, b[0].first, a[0].first, a[0].first);
    if (!cmp1 && !cmp2) {
      return 0;
    }
    if (cmp1) {
      return -1;
    }
    return 1;
  }
  int lcp = sops.string_lcp(a[0].first, b[0].first);
  lcp = min({lcp, a[0].second - a[0].first + 1, b[0].second - b[0].first + 1});
  int nx = a[0].first + lcp - 1, ny = b[0].first + lcp - 1;
  vector<pair<int, int>> na, nb;
  if (nx >= a[0].second) {
    for (int i = 1; i < a.size(); ++i) {
      na.push_back(a[i]);
    }
  }
  if (ny >= b[0].second) {
    for (int i = 1; i < b.size(); ++i) {
      nb.push_back(b[i]);
    }
  }
  if (nx < a[0].second) {
    na.push_back(make_pair(nx + 1, a[0].second));
    for (int i = 1; i < a.size(); ++i) {
      na.push_back(a[i]);
    }
  }
  if (ny < b[0].second) {
    nb.push_back(make_pair(ny + 1, b[0].second));
    for (int i = 1; i < b.size(); ++i) {
      nb.push_back(b[i]);
    }
  }
  return cmp2(na, nb);
}
bool cmp(const pair<int, int>& a, const pair<int, int>& b) {
  int nlen1 = get_nlength(a);
  int nlen2 = get_nlength(b);
  if (nlen1 == 0 && nlen2 == 0) {
    if (a.first == u & b.first == v) {
      return true;
    }
    return false;
  }
  if (nlen1 == 0) {
    return true;
  }
  if (nlen2 == 0) {
    return false;
  }
  int l1, r1, l2, r2;
  fill_segs(l1, r1, l2, r2, a);
  int p1, q1, p2, q2;
  fill_segs(p1, q1, p2, q2, b);
  vector<pair<int, int>> na;
  vector<pair<int, int>> nb;
  na.push_back(make_pair(l1, r1));
  if (l2 != -1) {
    na.push_back(make_pair(l2, r2));
  }
  nb.push_back(make_pair(p1, q1));
  if (p2 != -1) {
    nb.push_back(make_pair(p2, q2));
  }
  int val = cmp2(na, nb);
  if (val == 0) {
    if (a.first == u && b.first == v) {
      return true;
    }
    return false;
  }
  return val == -1;
}
bool cmpst(const pair<string, pair<int, int>>& a,
           const pair<string, pair<int, int>>& b) {
  if (a.first < b.first) {
    return true;
  }
  if (a.first > b.first) {
    return false;
  }
  if (a.first == b.first) {
    if (a.second.first == u && b.second.first == v) {
      return true;
    }
    return false;
  }
}
struct Node {
  Node() { left = right = nullptr; }
  int idxleft, idxright;
  Node* left;
  Node* right;
};
void dfs(Node* root, vector<int>& order) {
  if (!root) {
    return;
  }
  if (root->left) {
    dfs(root->left, order);
  }
  for (int i = root->idxleft; i <= root->idxright; ++i) {
    order.push_back(i);
  }
  if (root->right) {
    dfs(root->right, order);
  }
}
vector<pair<int, int>> get_order(const string& s) {
  int n = s.length();
  Node* root = new Node();
  Node* curnode = root;
  for (int i = 0; i < n;) {
    int cur = i;
    while (cur < n && s[cur] == s[i]) {
      ++cur;
    }
    curnode->idxleft = i, curnode->idxright = cur - 1;
    if (cur == n) {
      break;
    }
    if (s[i] < s[cur]) {
      Node* left = new Node();
      curnode->left = left;
      curnode = curnode->left;
    } else {
      Node* right = new Node();
      curnode->right = right;
      curnode = curnode->right;
    }
    i = cur;
  }
  vector<int> order;
  dfs(root, order);
  int ps = n;
  for (int i = 0; i < n; ++i) {
    if (order[i] == n - 1) {
      ps = i + 1;
      break;
    }
  }
  vector<pair<int, int>> result;
  for (int i = 0; i < ps; ++i) {
    result.push_back(make_pair(v, order[i]));
  }
  result.push_back(make_pair(v, n));
  for (int i = ps; i < n; ++i) {
    result.push_back(make_pair(v, order[i]));
  }
  return result;
}
int dp[2][maxN];
int dp2[2][maxN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  for (int i = 0; i <= s[0].length(); ++i) {
    dp[u][i] = 1;
    dp2[u][i] = 1;
  }
  sops = StringOps(s[0]);
  len1 = 0, len2 = s[0].length();
  vector<pair<int, int>> order[2];
  u = 1, v = 0;
  order[0] = get_order(s[0]);
  swap(u, v);
  for (int i = 0; i + 1 < n; ++i) {
    string s1 = s[i];
    string s2 = s[i + 1];
    string nw = s1 + s2;
    len1 = s1.length(), len2 = s2.length();
    sops = StringOps(nw);
    order[v] = get_order(s[i + 1]);
    int cadd = 0;
    int head1 = 0, head2 = 0;
    while (head1 < order[u].size() || head2 < order[v].size()) {
      if (head1 == order[u].size()) {
        dp[v][order[v][head2].second] = cadd;
        ++head2;
      } else if (head2 == order[v].size()) {
        break;
      } else {
        if (cmp(order[u][head1], order[v][head2])) {
          cadd += dp[u][order[u][head1].second];
          if (cadd >= MOD) {
            cadd -= MOD;
          }
          ++head1;
        } else {
          dp[v][order[v][head2].second] = cadd;
          ++head2;
        }
      }
    }
    swap(u, v);
  }
  int res = 0;
  int res2 = 0;
  for (int i = 0; i <= s.back().length(); ++i) {
    res += dp[u][i];
    if (res >= MOD) {
      res -= MOD;
    }
    res2 += dp2[u][i];
    if (res2 >= MOD) {
      res2 -= MOD;
    }
  }
  cout << res << endl;
  return 0;
}
