#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename T, typename S>
inline ostream& operator<<(ostream& os, const pair<T, S> p) {
  cout << "[" << p.first << ";" << p.second << "]";
  return os;
}
template <typename T>
inline ostream& operator<<(ostream& os, const vector<T>& v) {
  for (auto el : v) cout << el << " ";
  return os;
}
template <typename T>
inline ostream& operator<<(ostream& os, const set<T>& v) {
  for (auto el : v) cout << el << " ";
  return os;
}
template <typename T, typename S>
inline ostream& operator<<(ostream& os, const map<T, S>& v) {
  for (auto el : v) cout << el << " ";
  return os;
}
template <typename T>
inline ostream& operator<<(ostream& os, const multiset<T>& v) {
  for (auto el : v) cout << el << " ";
  return os;
}
namespace ___debug {
struct DebugStream {
 private:
  bool is_first;

 public:
  DebugStream(bool _is_first) : is_first(_is_first) {}
  template <typename T>
  DebugStream operator<<(const T& value) const {
    assert(0);
    if (is_first) cout << "[DBG] ";
    cout << value;
    return DebugStream(false);
  };
  template <typename T>
  DebugStream printArray(T* l, T* r) {
    assert(0);
    if (is_first) cout << "[DBG] ";
    while (l != r) {
      cout << (*l);
      ++l;
      if (l == r) {
        cout << '\n';
      } else {
        cout << ' ';
      }
    }
    return DebugStream(false);
  }
};
DebugStream instance(true);
};  // namespace ___debug
const int INT_INF = (int)(2e9);
const ll LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
inline ll randint(ll a, ll b) {
  ll w = (_g() << 31LL) ^ _g();
  return a + w % (b - a + 1);
}
inline void fast_io() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
};
template <typename T>
inline T sign(T x) {
  return T(x > 0) - T(x < 0);
}
template <typename T>
inline T fetch() {
  T ret;
  cin >> ret;
  return ret;
}
template <typename T>
inline vector<T> fetch_vec(int sz) {
  vector<T> ret(sz);
  for (auto& elem : ret) cin >> elem;
  return ret;
}
template <typename T>
inline void makeUnique(vector<T>& v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
}
const int MOD = (int)1e9 + 7;
inline int add(int x, int y) { return (x + y >= MOD ? x + y - MOD : x + y); }
inline int sub(int x, int y) { return (x - y < 0 ? x - y + MOD : x - y); }
inline int mult(int x, int y) {
  ll r = x * 1LL * y;
  if (r >= MOD) r %= MOD;
  return r;
}
inline int binpow(int x, int y) {
  if (x == 1 || y == 0) return 1;
  if (x == 0) return 0;
  int rez = binpow(x, y >> 1);
  rez = mult(rez, rez);
  if (y & 1) rez = mult(rez, x);
  return rez;
}
inline int divide(int x, int y) { return mult(x, binpow(y, MOD - 2)); }
const int MAXN = 1007;
string S[MAXN];
int n;
vector<int> FirstDiff[MAXN], FirstDiffOffset[MAXN], FirstDiffOffset2[MAXN],
    dp[MAXN];
char safeReadCh(const string& s, int i) {
  return (i < ((int)(s).size()) ? s[i] : '$');
}
int checkStupid(int a, int i, int j) {
  string s, t;
  for (int p = 0; p < ((int)(S[a]).size()); ++p) {
    if (p != i) {
      s.push_back(S[a][p]);
    }
  }
  for (int q = 0; q < ((int)(S[a + 1]).size()); ++q) {
    if (q != j) {
      t.push_back(S[a + 1][q]);
    }
  }
  return s <= t;
}
int check(int a, int i, int j) {
  if (i < ((int)(S[a]).size()) && j < ((int)(S[a + 1]).size())) {
    if (((int)(S[a]).size()) == 1) {
      return 1;
    }
    if (((int)(S[a + 1]).size()) == 1) {
      return 0;
    }
    if (i < j) {
      int p = FirstDiff[a][0];
      if (p < i) {
        return S[a][p] <= S[a + 1][p];
      }
      p = FirstDiffOffset[a][i + 1];
      if (p <= j) {
        return S[a][p] <= S[a + 1][p - 1];
      }
      p = FirstDiff[a][j + 1];
      42;
      ;
      return safeReadCh(S[a], p) <= safeReadCh(S[a + 1], p);
    } else if (i > j) {
      int p = FirstDiff[a][0];
      if (p < j) {
        return S[a][p] <= S[a + 1][p];
      }
      p = FirstDiffOffset2[a][j + 1];
      42;
      ;
      if (p <= i) {
        return S[a][p - 1] <= S[a + 1][p];
      }
      p = FirstDiff[a][i + 1];
      return safeReadCh(S[a], p) <= safeReadCh(S[a + 1], p);
    } else {
      int p = FirstDiff[a][0];
      if (p < i) {
        return S[a][p] <= S[a + 1][p];
      }
      p = FirstDiff[a][i + 1];
      return safeReadCh(S[a], p) <= safeReadCh(S[a + 1], p);
    }
  } else {
    if (i < ((int)(S[a]).size())) {
      int p = FirstDiff[a][0];
      if (p < i) {
        return S[a][p] <= S[a + 1][p];
      }
      p = FirstDiffOffset[a][i + 1];
      return safeReadCh(S[a], p) <= safeReadCh(S[a + 1], p - 1);
    } else {
      int p = FirstDiff[a][0];
      if (p < j) {
        return S[a][p] <= S[a + 1][p];
      }
      p = FirstDiffOffset2[a][j + 1];
      return safeReadCh(S[a], p - 1) <= safeReadCh(S[a + 1], p);
    }
  }
}
void solve() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> S[i];
  }
  for (int i = 0; i < n - 1; ++i) {
    int k = max(((int)(S[i]).size()), ((int)(S[i + 1]).size()));
    FirstDiff[i].resize(k + 1);
    FirstDiff[i][k] = k;
    for (int p = k - 1; p >= 0; --p) {
      if (safeReadCh(S[i], p) != safeReadCh(S[i + 1], p)) {
        FirstDiff[i][p] = p;
      } else {
        FirstDiff[i][p] = FirstDiff[i][p + 1];
      }
    }
    42;
    ;
  }
  for (int i = 0; i < n - 1; ++i) {
    int k = max(((int)(S[i]).size()) + 1, ((int)(S[i + 1]).size()));
    FirstDiffOffset[i].resize(k + 1);
    FirstDiffOffset[i][k] = k;
    for (int p = k - 1; p > 0; --p) {
      if (safeReadCh(S[i], p) != safeReadCh(S[i + 1], p - 1)) {
        FirstDiffOffset[i][p] = p;
      } else {
        FirstDiffOffset[i][p] = FirstDiffOffset[i][p + 1];
      }
    }
    42;
    ;
  }
  for (int i = 0; i < n - 1; ++i) {
    int k = max(((int)(S[i]).size()), ((int)(S[i + 1]).size()) + 1);
    FirstDiffOffset2[i].resize(k + 1);
    FirstDiffOffset2[i][k] = k;
    for (int p = k - 1; p > 0; --p) {
      if (safeReadCh(S[i], p - 1) != safeReadCh(S[i + 1], p)) {
        FirstDiffOffset2[i][p] = p;
      } else {
        FirstDiffOffset2[i][p] = FirstDiffOffset2[i][p + 1];
      }
    }
    42;
    ;
  }
  if (0) {
    42;
    ;
    for (int a = 0; a + 1 < n; ++a) {
      for (int i = 0; i <= ((int)(S[a]).size()); ++i) {
        for (int j = 0; j <= ((int)(S[a + 1]).size()); ++j) {
          int stupid = checkStupid(a, i, j);
          int fast = check(a, i, j);
          if (stupid != fast) {
            cout << a << ' ' << i << ' ' << j << '\n';
            42;
            ;
            42;
            ;
            42;
            ;
            42;
            ;
            throw;
          }
        }
      }
    }
  }
  dp[0].resize(((int)(S[0]).size()) + 1, 1 % MOD);
  for (int p = 0; p <= ((int)(S[0]).size()); ++p) {
  }
  42;
  ;
  for (int i = 1; i < n; ++i) {
    dp[i].resize(((int)(S[i]).size()) + 1, 0 % MOD);
    for (int p = 0; p <= ((int)(S[i]).size()); ++p) {
      for (int q = 0; q <= ((int)(S[i - 1]).size()); ++q) {
        if (check(i - 1, q, p)) {
          dp[i][p] = add(dp[i][p], dp[i - 1][q]);
        }
      }
    }
    42;
    ;
  }
  int answ = 0;
  for (auto& v : dp[n - 1]) {
    answ = add(answ, v);
  }
  cout << answ << '\n';
}
int main() {
  fast_io();
  solve();
  return 0;
}
