#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

const int N = 123456;

string s[N];
int id[N], col[N];
int v;

int g1(int id, int i) {
  return s[id][i - 1];
}

int g2(int id, int i) {
  return s[id][s[id].length() - i];
}

bool byfirst(int i, int j) {
  return g1(i, v) < g1(j, v);
}

bool bylast(int i, int j) {
  return g2(i, v) < g2(j, v);
}

int main() {
  freopen("list.in", "r", stdin);
  freopen("list.out", "w", stdout);
  int n;
  scanf("%d", &n);
  int mlen = 0;
  for (int i = 0; i < n; i++) {
    int c = getchar();
    s[i] = "";
    while (c <= 32) c = getchar();
    while (c > 32) {
      s[i] += (char) c;
      c = getchar();
    }
    id[i] = i;
    if ((int) s[i].length() > mlen) mlen = s[i].length();
  }
  printf("%d\n", mlen);
  for (v = 1; v <= mlen; v++) {
    int j = 0;
    for (int i = 0; i < n; i++) {
      if ((int) s[id[i]].length() >= v) {
        id[j++] = id[i];
      }
    }
    n = j;
    for (int i = 0; i < n; ) {
      int j = i;
      while (j < n && col[id[i]] == col[id[j]]) {
        ++j;
      }
      std::sort(id + i, id + j, byfirst);
      i = j;
    }
    for (int i = 0; i < n; ) {
      int j = i;
      while (j < n && col[id[i]] == col[id[j]] && g1(id[i], v) == g1(id[j], v)) {
        ++j;
      }
      std::sort(id + i, id + j, bylast);
      i = j;
    }
    long long ans = 0;
    int coln = 0;
    for (int i = 0; i < n; ) {
      int j = i;
      while (j < n && col[id[i]] == col[id[j]] && g1(id[i], v) == g1(id[j], v) && g2(id[i], v) == g2(id[j], v)) ++j;
      ans += (long long) (j - i) * (j - i - 1) / 2;
      while (i < j) col[id[i++]] = coln;
      ++coln;
    }
    printf("%I64d\n", ans);
  }
}
