#include <bits/stdc++.h>
void init_hash(int *h, char *s, int base, int mod, int lim);
int get_hash(int *h, int *pw, int mod, int l, int r);
const int m1 = 998244353, m2 = 1e9 + 7, b1 = 17, b2 = 23;
std::vector<int> ch[100005];
int id[35][100005], len[35], n, ans, flag, sr, ins[100005], vis[100005], tl,
    h1[35][100005], h2[35][100005], pw1[100005], pw2[100005];
char s[35][100005];
int match(int i, int j, int k) {
  int L = std::min(len[i] - j + 1, len[k]);
  if (get_hash(h1[i], pw1, m1, j, j + L - 1) ==
          get_hash(h1[k], pw1, m1, 1, L) &&
      get_hash(h2[i], pw2, m2, j, j + L - 1) == get_hash(h2[k], pw2, m2, 1, L))
    return 1;
  return 0;
}
void link(int i, int j, int k, int l) {
  if (k == sr) {
    ch[id[i][j]].push_back(sr);
    return;
  }
  ch[id[i][j]].push_back(id[k][l]);
}
void dfs(int x) {
  if (flag) return;
  ins[x] = vis[x] = 1;
  for (int y : ch[x]) {
    if (ins[y]) {
      flag = 1;
      return;
    }
    if (!vis[y]) dfs(y);
  }
  ins[x] = 0;
}
int check(int l, int r) {
  std::memset(vis, 0, sizeof(vis));
  std::memset(ins, 0, sizeof(ins));
  for (int i = 1; i <= tl; ++i) ch[i].clear();
  ch[sr].clear();
  flag = 0;
  for (int i = l; i <= r; ++i) {
    for (int j = 1; j <= len[i]; ++j) {
      for (int k = l; k <= r; ++k) {
        if (len[i] - j + 1 < len[k]) {
          if (match(i, j, k)) link(i, j, k, len[i] - j + 1 + 1);
        }
        if (len[i] - j + 1 == len[k]) {
          if (j == 1 && len[i] == len[k]) continue;
          if (match(i, j, k)) link(i, j, sr, 0);
        }
        if (len[i] - j + 1 > len[k]) {
          if (match(i, j, k)) link(i, j, i, j + len[k]);
        }
      }
    }
  }
  for (int i = 1; i <= n; ++i) ch[sr].push_back(id[i][1]);
  for (int i = 1; i <= tl + 1; ++i) dfs(i);
  return flag ^ 1;
}
const int lim = 1e5;
signed main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); ++i) {
    scanf("%s", s[i] + 1);
    len[i] = std::strlen(s[i] + 1);
    for (int j = (1); j <= (len[i]); ++j) id[i][j] = ++tl;
  }
  sr = tl + 1;
  int r = 0;
  pw1[0] = pw2[0] = 1;
  for (int i = 1; i <= lim; ++i) pw1[i] = (long long)pw1[i - 1] * b1 % m1;
  for (int i = 1; i <= lim; ++i) pw2[i] = (long long)pw2[i - 1] * b2 % m2;
  for (int i = (1); i <= (n); ++i) {
    init_hash(h1[i], s[i], b1, m1, lim);
    init_hash(h2[i], s[i], b2, m2, lim);
  }
  for (int l = 1; l <= n; ++l) {
    if (r < l - 1) r = l - 1;
    while (r < n && check(l, r + 1)) r++;
    ans += r - l + 1;
  }
  printf("%d", ans);
  return 0;
}
void init_hash(int *h, char *s, int base, int mod, int lim) {
  for (int i = 1; i <= lim; ++i)
    h[i] = ((long long)h[i - 1] * base + s[i] - 'a') % mod;
}
int get_hash(int *h, int *pw, int mod, int l, int r) {
  return (h[r] - (long long)pw[r - l + 1] * h[l - 1] % mod + mod) % mod;
}
