#include <bits/stdc++.h>
using namespace std;
const int N = 30, M = 100000;
const int M0 = 998244853, M1 = 19260817, P0 = 131, P1 = 13331;
struct hasher {
  int x, y;
  hasher(int X = 0, int Y = 0) {
    x = X;
    y = Y;
  }
  hasher operator+(const char &p) const {
    return hasher((1LL * x * P0 + p) % M0, (1LL * y * P1 + p) % M1);
  }
  hasher operator-(const hasher &p) const {
    return hasher((x - p.x + M0) % M0, (y - p.y + M1) % M1);
  }
  hasher operator*(const hasher &p) const {
    return hasher(1LL * x * p.x % M0, 1LL * y * p.y % M1);
  }
  bool operator==(const hasher &p) const { return x == p.x && y == p.y; }
  bool operator!=(const hasher &p) const { return x ^ p.x || y ^ p.y; }
} pw[M + 9];
void Get_pw() {
  pw[0] = hasher(1, 1);
  for (int i = 1; i <= M; ++i) pw[i] = pw[i - 1] * hasher(P0, P1);
}
hasher Get_hash(hasher *h, int l, int r) {
  return h[r] - h[l - 1] * pw[r - l + 1];
}
int n, len[N + 9];
int id[N + 9][M + 9], bel[M + 9], cn;
char s[N + 9][M + 9];
hasher hs[N + 9][M + 9];
void into() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", s[i] + 1);
    len[i] = strlen(s[i] + 1);
    for (int j = 1; j <= len[i]; ++j) {
      bel[id[i][j] = ++cn] = i;
      hs[i][j] = hs[i][j - 1] + s[i][j];
    }
  }
  ++cn;
}
struct side {
  int y, a, b;
  side(int Y = 0, int A = 0, int B = 0) {
    y = Y;
    a = A;
    b = B;
  }
};
vector<side> e[M + 9];
void Get_graph() {
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      for (int k = 1; k <= len[i]; ++k) {
        if (k == 1 && len[i] == len[j] && hs[i][len[i]] == hs[j][len[j]])
          continue;
        int u = k == 1 ? cn : id[i][k - 1];
        int p = k + len[j] - 1;
        int v = p == len[i]  ? cn
                : p < len[i] ? id[i][p]
                             : id[j][len[i] - k + 1];
        if (Get_hash(hs[i], k, min(p, len[i])) ==
            Get_hash(hs[j], 1, min(len[j], len[i] - k + 1)))
          e[u].push_back(side(v, i, j));
      }
}
int vis[M + 9], lop[M + 9];
bool Dfs_ans(int k, int l, int r) {
  vis[k] = lop[k] = 1;
  for (int vs = e[k].size(), i = 0; i < vs; ++i) {
    int y = e[k][i].y, a = e[k][i].a, b = e[k][i].b;
    if (a < l || a > r || b < l || b > r) continue;
    if (lop[y]) return 0;
    if (!Dfs_ans(y, l, r)) return 0;
  }
  lop[k] = 0;
  return 1;
}
bool Get_ans(int l, int r) {
  for (int i = 1; i <= cn; ++i) vis[i] = lop[i] = 0;
  for (int i = 1; i <= cn; ++i)
    if (!vis[i])
      if (i ^ cn && l <= bel[i] && bel[i] <= r && !Dfs_ans(i, l, r)) return 0;
  return 1;
}
int ans;
void Get_ans() {
  for (int i = 1; i <= n; ++i)
    for (int j = i; j <= n; ++j) ans += Get_ans(i, j);
}
void work() {
  Get_pw();
  Get_graph();
  Get_ans();
}
void outo() { printf("%d\n", ans); }
int main() {
  into();
  work();
  outo();
  return 0;
}
