#include <bits/stdc++.h>
using namespace std;
const int N = 35;
const int M = 100005;
const int mo[2] = {998244353, 1000000009};
int n, ans, tot, L[N];
int a[2][N][M], b[2][M];
int id[N][M], head[M], q[M], deg[M];
char s[M];
struct edge {
  int to, next;
} e[N * M];
void add(int x, int y) {
  e[++tot] = (edge){y, head[x]};
  head[x] = tot;
  deg[y]++;
}
bool same(int x, int l1, int r1, int y, int l2, int r2) {
  for (int k = (int)(0); k <= (int)(1); k++) {
    int hsh1 = (a[k][x][r1] - a[k][x][l1 - 1] + mo[k]) % mo[k];
    int hsh2 = (a[k][y][r2] - a[k][y][l2 - 1] + mo[k]) % mo[k];
    if (l1 < l2)
      hsh1 = 1ll * hsh1 * b[k][l2 - l1] % mo[k];
    else
      hsh2 = 1ll * hsh2 * b[k][l1 - l2] % mo[k];
    if (hsh1 != hsh2) return 0;
  }
  return 1;
}
bool check(int l, int r) {
  int cnt = 1;
  tot = 0;
  for (int i = (int)(l); i <= (int)(r); i++)
    for (int j = (int)(1); j <= (int)(L[i]); j++) id[i][j] = ++cnt;
  for (int i = (int)(1); i <= (int)(cnt); i++) head[i] = deg[i] = 0;
  for (int i = (int)(l); i <= (int)(r); i++)
    for (int j = (int)(1); j <= (int)(L[i]); j++)
      for (int k = (int)(l); k <= (int)(r); 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])) add(id[i][j], 1);
        } else if (L[i] - j + 1 > L[k]) {
          if (same(i, j, j + L[k] - 1, k, 1, L[k]))
            add(id[i][j], id[i][j + L[k]]);
        } else {
          if (same(i, j, L[i], k, 1, L[i] - j + 1))
            add(id[i][j], id[k][L[i] - j + 2]);
        }
      }
  for (int i = (int)(l); i <= (int)(r); i++) add(1, id[i][1]);
  int h = 0, t = 0;
  for (int i = (int)(1); i <= (int)(cnt); i++)
    if (!deg[i]) q[++t] = i;
  while (h != t) {
    int x = q[++h];
    for (int i = head[x]; i; i = e[i].next)
      if (!(--deg[e[i].to])) q[++t] = e[i].to;
  }
  return t == cnt;
}
int main() {
  scanf("%d", &n);
  for (int i = (int)(1); i <= (int)(n); i++) {
    scanf("%s", s + 1);
    L[i] = strlen(s + 1);
    for (int k = (int)(0); k <= (int)(1); k++) {
      b[k][0] = 1;
      for (int j = (int)(1); j <= (int)(L[i]); 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];
      }
    }
  }
  int j = 1;
  for (int i = (int)(1); i <= (int)(n); i++) {
    for (; j <= n && check(i, j); j++)
      ;
    ans += j - i;
  }
  printf("%d\n", ans);
}
