#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int mod = 998244353;
const int base = 131;
char str[31][maxn];
int zip[31][maxn];
int id[31][maxn];
int n, pw[maxn], inc[maxn], len[maxn], tot, maxl;
vector<int> adj[maxn];
int deg[maxn], s[maxn];
queue<int> Q;
int fpm(int p, int k) {
  int res = 1;
  for (; k; k >>= 1, p = (long long)p * p % mod)
    if (k & 1) res = (long long)res * p % mod;
  return res;
}
int Hash(int i, int l, int r) {
  int _zip = (long long)(zip[i][r] - zip[i][l - 1]) * inc[l] % mod;
  return _zip < 0 ? _zip + mod : _zip;
}
bool check(int l, int r) {
  if (l > r) return true;
  for (int i = s[r]; i >= s[l - 1]; i--) adj[i].clear(), deg[i] = 0;
  int ex = s[l - 1];
  for (int i = l; i <= r; i++)
    for (int j = l; j <= r; j++)
      for (int t = 1; t < len[i]; t++) {
        if (t == len[j]) {
          if (Hash(i, len[i] - t + 1, len[i]) == Hash(j, 1, t))
            adj[id[i][t]].push_back(ex), ++deg[ex];
          ;
        } else if (t < len[j]) {
          if (Hash(i, len[i] - t + 1, len[i]) == Hash(j, 1, t))
            adj[id[i][t]].push_back(id[j][len[j] - t]),
                ++deg[id[j][len[j] - t]];
          ;
        } else {
          if (Hash(i, len[i] - t + 1, len[i] - t + len[j]) ==
              Hash(j, 1, len[j]))
            adj[id[i][t]].push_back(id[i][t - len[j]]),
                ++deg[id[i][t - len[j]]];
          ;
        }
      }
  for (int i = l; i <= r; i++)
    for (int j = l; j <= r; j++)
      if (len[i] > len[j] && Hash(i, 1, len[j]) == Hash(j, 1, len[j]))
        adj[ex].push_back(id[i][len[i] - len[j]]),
            ++deg[id[i][len[i] - len[j]]];
  ;
  int cnt = s[r] - s[l - 1] + 1;
  for (int i = s[r]; i >= s[l - 1]; i--)
    if (!deg[i]) Q.push(i);
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    --cnt;
    for (auto v : adj[u])
      if (!--deg[v]) Q.push(v);
  }
  return cnt == 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= (n); i++) {
    scanf("%s", str[i] + 1);
    len[i] = strlen(str[i] + 1);
    for (int j = (len[i] - 1); j >= 1; j--) id[i][j] = ++tot;
    maxl = max(maxl, len[i]);
    s[i] = tot;
  }
  pw[0] = 1;
  inc[0] = 1;
  int _inc = fpm(base, mod - 2);
  for (int i = 1; i <= (maxl); i++) pw[i] = (long long)pw[i - 1] * base % mod;
  for (int i = 1; i <= (maxl); i++) inc[i] = (long long)inc[i - 1] * _inc % mod;
  for (int i = 1; i <= (n); i++) {
    for (int j = 1; j <= (len[i]); j++)
      zip[i][j] = (zip[i][j - 1] + (long long)pw[j] * str[i][j]) % mod;
  }
  int ans = 0;
  for (int j = 0, i = 1; i <= n; i++) {
    while (j < n && check(i, j + 1)) ++j;
    ans += j - i + 1;
  }
  printf("%d", ans);
  return 0;
}
