#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s[n];
  for (int i = 0; i < (n); ++i) cin >> s[i];
  long long int MOD = 1000000007;
  long long int dp1[20005], dp2[20005];
  for (int i = 0; i < (n); ++i) {
    int m = s[i].size();
    for (int j = 0; j < (m + 1); ++j) {
      dp2[j] = 0;
    }
    if (i == 0) {
      for (int j = 0; j < (m + 1); ++j) {
        dp2[j] = 1;
      }
    } else {
      deque<int> t1, t2;
      vector<pair<string, int>> t;
      int w = s[i - 1].size();
      t1.push_back(w);
      int flag = 0;
      for (int j = (w)-1; j >= 0; --j) {
        if (j == w - 1) {
          t1.push_front(j);
        } else {
          if (s[i - 1][j] > s[i - 1][j + 1]) {
            flag = 0;
          } else if (s[i - 1][j] < s[i - 1][j + 1]) {
            flag = 1;
          }
          if (flag == 0) {
            t1.push_front(j);
          } else {
            t1.push_back(j);
          }
        }
      }
      t2.push_back(m);
      flag = 0;
      for (int j = (m)-1; j >= 0; --j) {
        if (j == m - 1) {
          t2.push_front(j);
        } else {
          if (s[i][j] > s[i][j + 1]) {
            flag = 0;
          } else if (s[i][j] < s[i][j + 1]) {
            flag = 1;
          }
          if (flag == 0) {
            t2.push_front(j);
          } else {
            t2.push_back(j);
          }
        }
      }
      long long int now = 0;
      int j1 = 0, j2 = 0;
      while (true) {
        if (j1 == w + 1 && j2 == m + 1) {
          break;
        } else if (j1 == w + 1) {
          dp2[t2[j2]] = now;
          j2++;
        } else if (j2 == m + 1) {
          now += dp1[t1[j1]];
          now %= MOD;
          j1++;
        } else {
          string ss1 = s[i - 1];
          if (t1[j1] < w) {
            ss1.erase(t1[j1], 1);
          }
          string ss2 = s[i];
          if (t2[j2] < m) {
            ss2.erase(t2[j2], 1);
          }
          if (ss1 <= ss2) {
            now += dp1[t1[j1]];
            now %= MOD;
            j1++;
          } else {
            dp2[t2[j2]] = now;
            j2++;
          }
        }
      }
    }
    for (int j = 0; j < (m + 1); ++j) dp1[j] = dp2[j];
  }
  long long int ans = 0;
  for (int j = 0; j < (s[n - 1].size() + 1); ++j) {
    ans += dp1[j];
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}
