#include <bits/stdc++.h>
using namespace std;
const int maxn = 35;
const int maxm = 100010;
const int maxe = maxn * maxm;
struct edge {
  int to, next;
} e[maxe];
int head[maxm], e_num, ind[maxm], q[maxm];
void add_edge(int u, int v) {
  e[++e_num] = (edge){v, head[u]};
  head[u] = e_num;
  ++ind[v];
}
void e_init(int num) {
  e_num = 0;
  for (int i = 0; i < num; ++i) ind[i] = head[i] = 0;
}
char s[maxm], rr[maxm], g[maxm];
int st[maxn], len[maxn], n, m, z[maxm];
void z_box(int n) {
  z[0] = n;
  int r = -1, pos;
  for (int i = 1; i < n; ++i) {
    if (i <= r)
      z[i] = min(z[i - pos], r - i + 1);
    else
      z[i] = 0;
    while (i + z[i] < n && g[z[i]] == g[i + z[i]]) ++z[i];
    if (i + z[i] - 1 > r) r = i + z[i] - 1, pos = i;
  }
}
bool topo_sort(int n) {
  int hh, tt;
  hh = tt = 0;
  for (int i = 0; i < n; ++i)
    if (!ind[i]) q[tt++] = i;
  while (hh < tt) {
    int x = q[hh++];
    for (int i = head[x]; i; i = e[i].next) {
      --ind[e[i].to];
      if (!ind[e[i].to]) q[tt++] = e[i].to;
    }
  }
  return tt == n;
}
bool check(int sl, int sr) {
  e_init(st[sr] - st[sl] + len[sr] + 1);
  int m = st[sr] - st[sl] + len[sr];
  int cur;
  for (int i = sl; i <= sr; ++i) {
    add_edge(m, st[i] - st[sl]);
    for (int j = 0; j < len[i]; ++j) g[j] = s[st[i] + j];
    cur = len[i];
    for (int j = sl; j <= sr; ++j)
      if (i ^ j) {
        for (int k = 0; k < len[j]; ++k) g[cur + k] = s[st[j] + k];
        cur += len[j];
      }
    z_box(cur);
    for (int j = 1; j < len[i]; ++j)
      if (j + z[j] >= len[i])
        add_edge(st[i] + j - st[sl], st[i] + len[i] - j - st[sl]);
    cur = len[i];
    for (int j = sl; j <= sr; ++j)
      if (i ^ j) {
        if (len[i] == len[j] && z[cur] >= len[i]) {
          cur += len[j];
          continue;
        }
        for (int k = 0; k < len[j]; ++k) {
          z[cur + k] = min(min(z[cur + k], len[j] - k), len[i]);
          if (k + z[cur + k] >= len[j]) {
            int l = min(len[j] - k, len[i]);
            if (l == len[i])
              add_edge(st[j] + k - st[sl], m);
            else
              add_edge(st[j] + k - st[sl], st[i] + l - st[sl]);
          } else {
            if (z[cur + k] >= len[i])
              add_edge(st[j] + k - st[sl], st[j] + k + z[cur + k] - st[sl]);
          }
        }
        cur += len[j];
      }
  }
  int ans = topo_sort(m + 1);
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%s", rr);
    len[i] = strlen(rr);
    st[i] = m;
    for (int j = 0; j < len[i]; ++j) s[m + j] = rr[j];
    m += len[i];
  }
  int curl = -1, ans = 0;
  for (int curr = 0; curr < n; ++curr) {
    if (curl < curr) curl = curr - 1;
    while (curl + 1 < n && check(curr, curl + 1)) ++curl;
    ans += curl - curr + 1;
  }
  printf("%d\n", ans);
  return 0;
}
