#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
template <typename T>
inline void gn(T &first) {
  char c, sg = 0;
  while (c = getchar(), (c > '9' || c < '0') && c != '-')
    ;
  for ((c == '-' ? sg = 1, c = getchar() : 0), first = 0; c >= '0' && c <= '9';
       c = getchar())
    first = (first << 1) + (first << 3) + c - '0';
  if (sg) first = -first;
}
template <class T, class T1>
inline void gn(T &first, T1 &second) {
  gn(first);
  gn(second);
}
template <class T, class T1, class T2>
inline void gn(T &first, T1 &second, T2 &z) {
  gn(first);
  gn(second);
  gn(z);
}
template <typename T>
inline void print(T first) {
  if (first < 0) {
    putchar('-');
    return print(-first);
  }
  if (first < 10) {
    putchar('0' + first);
    return;
  }
  print(first / 10);
  putchar(first % 10 + '0');
}
template <typename T>
inline void println(T first) {
  print(first), putchar('\n');
}
template <typename T>
inline void printsp(T first) {
  print(first), putchar(' ');
}
template <class T, class T1>
inline void print(T first, T1 second) {
  printsp(first), println(second);
}
template <class T, class T1, class T2>
inline void print(T first, T1 second, T2 z) {
  printsp(first), printsp(second), println(z);
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
char s[100100], t[100100];
int cur, st[100100], len[100100];
int z[100100];
void Zval(char *s) {
  int n = strlen(s);
  z[0] = 0;
  for (int b = 0, i = 1; i < n; i++) {
    z[i] = max(min(z[i - b], z[b] + b - i), 0);
    while (s[i + z[i]] == s[z[i]]) z[i]++;
    if (i + z[i] > b + z[b]) b = i;
  }
}
vector<pair<int, int> > adj[100100];
int rid, vst[100100], low[100100], ins[100100], bel[100100], sz[100100];
int stk[100100], top, cnt;
int flag[100100];
int L, R;
void dfs(int u) {
  vst[u] = low[u] = ++rid;
  stk[++top] = u;
  ins[u] = 1;
  for (int i = 0; i < adj[u].size(); i++) {
    int via = adj[u][i].second;
    if (via < L || via > R) continue;
    int v = adj[u][i].first;
    if (u == v) flag[u] = 1;
    if (v != cur && (v < st[L] || v >= st[R] + len[R])) continue;
    if (!vst[v])
      dfs(v), smin(low[u], low[v]);
    else if (ins[v])
      smin(low[u], vst[v]);
  }
  if (vst[u] == low[u]) {
    cnt++;
    sz[cnt] = 0;
    while (1) {
      bel[stk[top]] = cnt;
      sz[cnt]++;
      ins[stk[top]] = 0;
      if (stk[top--] == u) break;
    }
  }
}
bool can(int L, int R) {
  ::L = L, ::R = R;
  adj[cur].clear();
  for (int i = L; i <= R; i++) adj[cur].push_back(pair<int, int>(st[i], i));
  for (int i = 0; i <= cur; i++) vst[i] = flag[i] = 0;
  rid = top = cnt = 0;
  dfs(cur);
  for (int i = st[L]; i < st[R] + len[R]; i++)
    if (!vst[i]) dfs(i);
  for (int i = L; i <= R; i++) {
    for (int j = 1; j < len[i]; j++)
      if (sz[bel[st[i] + j]] > 1 || flag[st[i] + j]) return false;
  }
  return true;
}
int main() {
  int n;
  gn(n);
  for (int i = 0; i < n; i++) {
    st[i] = cur;
    scanf("%s", s + cur);
    len[i] = strlen(s + cur);
    cur += len[i];
  }
  for (int a = 0; a < n; a++) {
    for (int b = 0; b < n; b++) {
      int m = 0;
      for (int i = 0; i < len[a]; i++) t[m++] = s[st[a] + i];
      t[m++] = '*';
      for (int i = 0; i < len[b]; i++) t[m++] = s[st[b] + i];
      t[m] = 0;
      Zval(t);
      for (int i = 1; i <= len[b]; i++) {
        if (z[m - i] == i && z[m - i] == len[a]) {
          adj[st[b] + len[b] - i].push_back(pair<int, int>(cur, a));
        } else if (z[m - i] == i) {
          adj[st[b] + len[b] - i].push_back(pair<int, int>(st[a] + i, a));
        } else if (z[m - i] == len[a]) {
          adj[st[b] + len[b] - i].push_back(
              pair<int, int>(st[b] + len[b] - i + len[a], a));
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0, j; i < n; i++) {
    for (j = i; j < n && can(i, j); j++)
      ;
    ans += j - i;
  }
  println(ans);
  return 0;
}
