#include <bits/stdc++.h>
using namespace std;
int IN() {
  int x = 0, f = 0, ch;
  for (; (ch = getchar()) < '0' || ch > '9';) f = (ch == '-');
  for (; ch >= '0' && ch <= '9'; (ch = getchar())) x = x * 10 + ch - '0';
  return f ? -x : x;
}
const int mo[] = {998244353, 1000000007};
int N, Ans, L[35];
int A[2][35][100005], B[2][100005];
char s[100005];
int C, D, ID[35][100005], st[100005], Deg[100005], Q[100005];
struct Lin {
  int v, next;
} E[35 * 100005];
void Link(int u, int v) {
  E[++D] = (Lin){v, st[u]};
  st[u] = D;
  Deg[v]++;
}
bool Same(int a, int l1, int r1, int b, int l2, int r2) {
  for (int k = 0, lim = 1; k <= lim; k++) {
    int u = (A[k][a][r1] - A[k][a][l1 - 1] + mo[k]) % mo[k],
        v = (A[k][b][r2] - A[k][b][l2 - 1] + mo[k]) % mo[k];
    if (l1 < l2)
      u = 1ll * u * B[k][l2 - l1] % mo[k];
    else
      v = 1ll * v * B[k][l1 - l2] % mo[k];
    if (u != v) return 0;
  }
  return 1;
}
bool check(int l, int r) {
  C = 1;
  for (int i = l, lim = r; i <= lim; i++)
    for (int j = 1, lim = L[i]; j <= lim; j++) ID[i][j] = ++C;
  for (int i = 1, lim = C; i <= lim; i++) st[i] = Deg[i] = 0;
  D = 0;
  for (int i = l, lim = r; i <= lim; i++)
    for (int j = 1, lim = L[i]; j <= lim; j++) {
      for (int k = l, lim = r; k <= lim; k++) {
        if (j == 1 && L[k] == L[i]) continue;
        if (L[i] - j + 1 == L[k]) {
          if (Same(i, j, L[i], k, 1, L[k])) Link(ID[i][j], 1);
        } else if (L[i] - j + 1 > L[k]) {
          if (Same(i, j, j + L[k] - 1, k, 1, L[k]))
            Link(ID[i][j], ID[i][j + L[k]]);
        } else {
          if (Same(i, j, L[i], k, 1, L[i] - j + 1))
            Link(ID[i][j], ID[k][L[i] - j + 2]);
        }
      }
    }
  for (int i = l, lim = r; i <= lim; i++) Link(1, ID[i][1]);
  *Q = 0;
  for (int i = 1, lim = C; i <= lim; i++)
    if (!Deg[i]) Q[++*Q] = i;
  for (int i = 1; i <= *Q; i++) {
    int u = Q[i];
    for (int j = st[u], v; j; j = E[j].next)
      if (!(--Deg[v = E[j].v])) Q[++*Q] = v;
  }
  return *Q == C;
}
int main(int argc, char* argv[]) {
  N = IN();
  for (int i = 1, lim = N; i <= lim; i++) {
    scanf("%s", s + 1);
    L[i] = strlen(s + 1);
    for (int k = 0, lim = 1; k <= lim; k++) {
      B[k][0] = 1;
      for (int j = 1, lim = L[i]; j <= lim; j++) {
        B[k][j] = 1ll * B[k][j - 1] * 233 % mo[k];
        A[k][i][j] = (A[k][i][j - 1] + 1ll * B[k][j] * s[j]) % mo[k];
      }
    }
  }
  for (int i = 1, j = 1; i <= N; i++) {
    for (; j <= N && check(i, j); j++)
      ;
    Ans += j - i;
  }
  printf("%d\n", Ans);
  return 0;
}
