#include <bits/stdc++.h>
using namespace std;
const int maxn = 35;
const int maxm = 100005;
const int H1 = 20190224;
const int mod1 = 998244353;
const int H2 = 23333333;
const int mod2 = 1e9 + 7;
int n, m, ql, qr, ans;
char s[maxm], c[maxm];
int vl[maxm], vr[maxm], h1[maxm], h2[maxm], pw1[maxm], pw2[maxm], deg[maxm],
    q[maxm];
vector<int> edge[maxm];
bool same(int l1, int r1, int l2, int r2) {
  int h11 =
      (h1[r1] - 1LL * (!l1 ? 0 : h1[l1 - 1]) * pw1[r1 - l1 + 1] % mod1 + mod1) %
      mod1;
  int h12 =
      (h2[r1] - 1LL * (!l1 ? 0 : h2[l1 - 1]) * pw2[r1 - l1 + 1] % mod2 + mod2) %
      mod2;
  int h21 =
      (h1[r2] - 1LL * (!l2 ? 0 : h1[l2 - 1]) * pw1[r2 - l2 + 1] % mod1 + mod1) %
      mod1;
  int h22 =
      (h2[r2] - 1LL * (!l2 ? 0 : h2[l2 - 1]) * pw2[r2 - l2 + 1] % mod2 + mod2) %
      mod2;
  return h11 == h21 && h12 == h22;
}
bool check(int l, int r) {
  for (int i = vl[l]; i <= vr[r]; i++) deg[i] = 0, edge[i].clear();
  deg[m] = 0;
  edge[m].clear();
  for (int i = l; i <= r; i++)
    for (int j = vl[i]; j <= vr[i]; j++) {
      for (int k = l; k <= r; k++) {
        if (vr[k] - vl[k] + 1 > vr[i] - j + 1) {
          if (same(j, vr[i], vl[k], vl[k] + vr[i] - j)) {
            deg[vl[k] + vr[i] - j + 1]++;
            edge[j].push_back(vl[k] + vr[i] - j + 1);
          }
        } else if (vr[k] - vl[k] + 1 < vr[i] - j + 1) {
          if (same(j, j + vr[k] - vl[k], vl[k], vr[k])) {
            deg[j + vr[k] - vl[k] + 1]++;
            edge[j].push_back(j + vr[k] - vl[k] + 1);
          }
        } else {
          if (j != vl[i] && same(j, vr[i], vl[k], vr[k])) {
            deg[m]++;
            edge[j].push_back(m);
          }
        }
      }
    }
  for (int i = l; i <= r; i++) deg[vl[i]]++, edge[m].push_back(vl[i]);
  ql = qr = 0;
  for (int i = vl[l]; i <= vr[r]; i++)
    if (!deg[i]) q[qr++] = i;
  if (!deg[m]) q[qr++] = m;
  while (ql < qr) {
    int x = q[ql++];
    for (int i = 0; i < (int(edge[x].size())); i++) {
      int y = edge[x][i];
      deg[y]--;
      if (!deg[y]) q[qr++] = y;
    }
  }
  return qr == vr[r] - vl[l] + 2;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (n); i++) {
    scanf("%s", c);
    vl[i] = m;
    int k = strlen(c);
    for (int j = 0; j < (k); j++) s[m++] = c[j];
    vr[i] = m - 1;
  }
  pw1[0] = pw2[0] = 1;
  for (int i = 1; i <= (m); i++) {
    pw1[i] = 1LL * pw1[i - 1] * H1 % mod1;
    pw2[i] = 1LL * pw2[i - 1] * H2 % mod2;
  }
  h1[0] = h2[0] = s[0];
  for (int i = 1; i <= (m - 1); i++) {
    h1[i] = (1LL * h1[i - 1] * H1 + s[i]) % mod1;
    h2[i] = (1LL * h2[i - 1] * H2 + s[i]) % mod2;
  }
  int r = 0;
  for (int l = 0; l < (n); l++) {
    r = max(r, l);
    while (r < n && check(l, r)) r++;
    ans += r - l;
  }
  printf("%d\n", ans);
  return 0;
}
