#include <bits/stdc++.h>
using namespace std;
const int N = 33, M = 100100;
int i, j, k, l, n, m, fg, ans, En;
char a[N][M];
int nn[N], z[M], h[M], b[N][M], p[N][M];
struct edge {
  int s, n;
} E[N * M];
void E_add(int x, int y) {
  E[++En].s = y;
  E[En].n = h[x];
  h[x] = En;
}
void dfs(int x) {
  if (fg) return;
  z[x] = 2;
  for (int k = h[x]; k; k = E[k].n) {
    if (!z[E[k].s])
      dfs(E[k].s);
    else {
      if (z[E[k].s] == 2) {
        fg = 1;
        return;
      }
    }
  }
  z[x] = 1;
}
bool check(int s, int t) {
  int i, j, k, l;
  fg = 0;
  En = 0;
  h[0] = z[0] = 0;
  for (i = b[s][1]; i <= b[t][nn[t]]; i++) h[i] = z[i] = 0;
  for (i = s; i <= t; i++) {
    E_add(0, b[i][1]);
    for (j = s; j <= t; j++) {
      l = 0;
      for (k = 1; k <= nn[i]; k++) {
        while (k + l <= nn[i] && 1 + l <= nn[j] && a[i][k + l] == a[j][1 + l])
          l++;
        if (l) {
          if (nn[i] - k + 1 < nn[j] && l == nn[i] - k + 1)
            E_add(b[i][k], b[j][1 + l]);
          if (nn[j] < nn[i] - k + 1 && l == nn[j]) E_add(b[i][k], b[i][k + l]);
          if (k > 1 && nn[i] - k + 1 == nn[j] && l == nn[j]) E_add(b[i][k], 0);
          l = p[j][l];
        }
      }
    }
  }
  if (!z[0]) dfs(0);
  if (fg) return 0;
  for (i = b[s][1]; i <= b[t][nn[t]]; i++)
    if (!z[i]) {
      dfs(i);
      if (fg) return 0;
    }
  return 1;
}
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%s", a[i] + 1);
    nn[i] = strlen(a[i] + 1);
    for (j = 1; j <= nn[i]; j++) b[i][j] = ++m;
  }
  for (i = 1; i <= n; i++) {
    k = 0;
    for (j = 2; j <= nn[i]; j++) {
      while (k && a[i][k + 1] != a[i][j]) k = p[i][k];
      if (a[i][k + 1] == a[i][j]) k++;
      p[i][j] = k;
    }
  }
  j = 1;
  for (i = 1; i <= n; i++) {
    if (i > j) j = i;
    while (j <= n && check(i, j)) j++;
    ans += j - i;
  }
  printf("%d\n", ans);
}
