#include <bits/stdc++.h>
using namespace std;
const int mo[] = {998244353, 1000000009};
const int N = 35, M = 100005;
int id[N][M];
int v[N][2][M], P[2][M];
int n, nd, L[N], q[M], deg[M];
vector<int> e[M];
char s[M];
bool same(int i, int j, int si, int sj, int l) {
  for (int f = (int)(0); f <= (int)(1); f++) {
    int vi = (v[i][f][si + l - 1] + mo[f] - v[i][f][si - 1]) % mo[f];
    int vj = (v[j][f][sj + l - 1] + mo[f] - v[j][f][sj - 1]) % mo[f];
    if (si <= sj)
      vi = 1ll * vi * P[f][sj - si] % mo[f];
    else
      vj = 1ll * vj * P[f][si - sj] % mo[f];
    if (vi != vj) return 0;
  }
  return 1;
}
void add(int x, int y) {
  e[x].push_back(y);
  ++deg[y];
}
bool topo() {
  int t = 0;
  for (int i = (int)(1); i <= (int)(nd); i++)
    if (!deg[i]) q[++t] = i;
  for (int i = (int)(1); i <= (int)(t); i++)
    for (auto j : e[q[i]])
      if (!--deg[j]) q[++t] = j;
  return t == nd;
}
bool check(int l, int r) {
  nd = 1;
  for (int i = (int)(l); i <= (int)(r); i++)
    for (int j = (int)(1); j <= (int)(L[i]); j++) id[i][j] = ++nd;
  for (int i = (int)(l); i <= (int)(r); i++) id[i][L[i] + 1] = 1;
  for (int i = (int)(1); i <= (int)(nd); i++) deg[i] = 0, e[i].resize(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;
        int len = min(L[i] - j + 1, L[k]);
        if (same(i, k, j, 1, len))
          add(id[i][j], id[i][j + len] + id[k][1 + len] - 1);
      }
  for (int i = (int)(l); i <= (int)(r); i++) add(1, id[i][1]);
  return topo();
}
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 f = (int)(0); f <= (int)(1); f++) {
      P[f][0] = 1;
      for (int j = (int)(1); j <= (int)(L[i]); j++) {
        P[f][j] = 1ll * P[f][j - 1] * 233 % mo[f];
        v[i][f][j] = (v[i][f][j - 1] + 1ll * P[f][j] * s[j]) % mo[f];
      }
    }
  }
  int j = 1, ans = 0;
  for (int i = (int)(1); i <= (int)(n); i++) {
    for (; j <= n && check(i, j); ++j)
      ;
    ans += j - i;
  }
  printf("%d\n", ans);
}
