#include <bits/stdc++.h>
using namespace std;
const int MAXN = 32, MAXS = 1 << 17;
const int MOD = 1e9 + 7, H = 3137;
int add(int a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}
int sub(int a, int b) {
  a -= b;
  if (a < 0) a += MOD;
  return a;
}
int mul(int a, int b) { return (int)(((long long)a * b) % MOD); }
int n, T;
string s[MAXN];
int len[MAXN];
int poz_s[MAXN];
vector<pair<int, pair<int, int> > > V[MAXS];
int __h[MAXS], pot[MAXS];
int *h = __h + 5;
int geth(int l, int ln) { return sub(h[l + ln - 1], mul(h[l - 1], pot[ln])); }
int ok(int a, int poza, int b) {
  int kol = min(len[b], len[a] - poza);
  return geth(poz_s[a] + poza, kol) == geth(poz_s[b], kol);
}
int slj_poz(int a, int poza, int b) {
  if (!ok(a, poza, b)) return -1;
  if (poza + len[b] == len[a]) return T;
  if (poza + len[b] < len[a]) return poz_s[a] + poza + len[b];
  return poz_s[b] + len[a] - poza;
}
char ss[MAXS];
void load() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf(" %s", ss);
    s[i] = ss;
    len[i] = (int)s[i].size();
    poz_s[i] = !i ? 0 : (poz_s[i - 1] + len[i - 1]);
    for (int j = 0; j < len[i]; j++)
      h[j + poz_s[i]] = add(mul(h[j + poz_s[i] - 1], H), s[i][j]);
  }
  T = poz_s[n - 1] + len[n - 1];
}
void gen() {
  for (int i = 0; i < n; i++) V[T].push_back({poz_s[i], pair<int, int>(i, i)});
  for (int a = 0; a < n; a++) {
    for (int b = 0; b < n; b++) {
      for (int poza = 0; poza < len[a]; poza++) {
        if (!poza && s[a] == s[b]) continue;
        int tmp = slj_poz(a, poza, b);
        if (tmp != -1)
          V[poz_s[a] + poza].push_back(
              {tmp, pair<int, int>(min(a, b), max(a, b))});
      }
    }
  }
}
int bio[MAXS];
int dfs(int node, int l, int r) {
  if (bio[node]) return bio[node] == 1;
  bio[node] = 1;
  for (auto it : V[node])
    if (it.second.first >= l && it.second.second <= r && dfs(it.first, l, r))
      return 1;
  bio[node] = 2;
  return 0;
}
int nema_cik(int l, int r) {
  memset(bio, 0, sizeof bio);
  for (int i = 0; i < T + 1; i++)
    if (!bio[i] && dfs(i, l, r)) return 0;
  return 1;
}
void solve() {
  int rje = 0;
  gen();
  for (int i = 0, j = 0; i < n; i++) {
    j = max(j, i);
    for (; j < n && nema_cik(i, j); j++)
      ;
    rje += j - i;
  }
  printf("%d\n", rje);
}
int main() {
  pot[0] = 1;
  for (int i = (1); i < (MAXS); i++) pot[i] = mul(pot[i - 1], H);
  load();
  solve();
  return 0;
}
