import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


// T: monoid
// op: T * T -> T
// query(a, b): returns t_a ... t_{b-1}
class SegmentTree(T, alias op) {
  import std.functional : binaryFun;
  alias opFun = binaryFun!op;
  const(T) idT;

  int n;
  T[] ts;
  this(int n_, const(T) idT) {
    this.idT = idT;
    for (n = 1; n < n_; n <<= 1) {}
    ts = new T[n << 1];
    ts[] = idT;
  }
  this(inout(T)[] ts_, const(T) idT) {
    this.idT = idT;
    const n_ = cast(int)(ts_.length);
    for (n = 1; n < n_; n <<= 1) {}
    ts = new T[n << 1];
    ts[0 .. n] = idT;
    ts[n .. n + n_] = ts_[];
    ts[n + n_ .. n << 1] = idT;
    build();
  }
  ref T at(int a) {
    return ts[n + a];
  }
  void build() {
    foreach_reverse (a; 1 .. n) ts[a] = opFun(ts[a << 1], ts[a << 1 | 1]);
  }
  void set(int a, const(T) val) {
    ts[a += n] = val;
    for (; a >>= 1; ) ts[a] = opFun(ts[a << 1], ts[a << 1 | 1]);
  }
  void mulL(int a, const(T) val) {
    set(a, opFun(val, ts[a + n]));
  }
  void mulR(int a, const(T) val) {
    set(a, opFun(ts[a + n], val));
  }
  T query(int a, int b) const {
    T prodL = idT, prodR = idT;
    for (a += n, b += n; a < b; a >>= 1, b >>= 1) {
      if (a & 1) prodL = opFun(prodL, ts[a++]);
      if (b & 1) prodR = opFun(ts[--b], prodR);
    }
    return opFun(prodL, prodR);
  }

  // min b s.t. pred(prod of [a, b)) (or n + 1 if no such b)
  //   0 <= a <= n
  //   assume pred(prod of [a, b)) is non-decreasing in b
  int binarySearchR(int a, bool delegate(T) pred) const {
    if (pred(idT)) return a;
    if (a == n) return n + 1;
    T prod = idT;
    for (a += n; ; a >>= 1) {
      if (a & 1) {
        if (pred(opFun(prod, ts[a]))) {
          for (; a < n; ) {
            a <<= 1;
            if (!pred(opFun(prod, ts[a]))) {
              prod = opFun(prod, ts[a++]);
            }
          }
          return a - n + 1;
        }
        prod = opFun(prod, ts[a++]);
        if (!(a & a - 1)) return n + 1;
      }
    }
  }

  // max a s.t. pred(prod of [a, b)) (or -1 if no such a)
  //   0 <= b <= n
  //   assume pred(prod of [a, b)) is non-increasing in a
  int binarySearchL(int b, bool delegate(T) pred) const {
    if (pred(idT)) return b;
    if (b == 0) return -1;
    T prod = idT;
    for (b += n; ; b >>= 1) {
      if ((b & 1) || b == 2) {
        if (pred(opFun(prod, ts[b - 1]))) {
          for (; b <= n; ) {
            b <<= 1;
            if (!pred(opFun(prod, ts[b - 1]))) {
              prod = opFun(prod, ts[--b]);
            }
          }
          return b - n - 1;
        }
        prod = opFun(prod, ts[--b]);
        if (!(b & b - 1)) return -1;
      }
    }
  }
}


enum INF = 10^^9;
enum A = 26;

void main() {
  /*
  debug {
    foreach (n; 1 .. 8 + 1) {
      auto vis = new bool[1 << n];
      vis[(1 << n) - 1] = 1;
      foreach_reverse (p; 0 .. 1 << n) {
        if (vis[p]) {
          if (popcnt(p) >= 2) {
            const u = bsf(p);
            const v = bsf(p ^ 1 << u);
            vis[p ^ 1 << u] = true;
            vis[p ^ 1 << v] = true;
          }
        }
      }
      writeln("n = ", n);
      foreach (p; 0 .. 1 << n) {
        if (vis[p]) {
          writeln(iota(n).filter!(u => (p & 1 << u)));
        }
      }
    }
  }
  //*/
  
  try {
    for (; ; ) {
      const N = readInt();
      auto S = new string[N];
      foreach (i; 0 .. N) {
        S[i] = readToken();
        S[i] = S[i].dup.reverse;
      }
      S.sort;
      debug {
        writeln("========");
        foreach (i; 0 .. N) {
          writeln(S[i]);
        }
      }
      
      auto L = new int[N];
      foreach (i; 0 .. N) {
        L[i] = cast(int)(S[i].length);
      }
      auto lcp = new int[N - 1];
      foreach (i; 0 .. N - 1) {
        int x;
        for (x = 0; x < L[i] && x < L[i + 1] && S[i][x] == S[i + 1][x]; ++x) {}
        lcp[i] = x;
      }
      debug {
        writeln("lcp = ", lcp);
      }
      auto segLcp = new SegmentTree!(int, min)(lcp, INF);
      auto segCnt = new SegmentTree!(int, "a + b")[A];
      foreach (a; 0 .. A) {
        segCnt[a] = new SegmentTree!(int, "a + b")(N, 0);
      }
      
      auto app = new bool[][](N, A);
      
      auto es = iota(N).array;
      es.sort!((i, j) => (L[i] > L[j]));
      long ans;
      int last = L.maxElement;
      for (int k = 0, l; k < N; k = l) {
        for (l = k; l < N && L[es[k]] == L[es[l]]; ++l) {}
        const p = L[es[k]] - 1;
        foreach (m; 0 .. l) {
          const i = es[m];
          foreach (x; p .. min(last, L[i])) {
            const a = S[i][x] - 'a';
            if (!app[i][a]) {
              debug {
                writeln("add ", a, " ", i);
              }
              app[i][a] = true;
              segCnt[a].mulR(i, 1);
            }
          }
        }
        last = p;
        foreach (m; k .. l) {
          const i = es[m];
          const a = S[i][p] - 'a';
          const posL = max(segLcp.binarySearchL(i, t => (t < p)) + 1, 0);
          const posR = min(segLcp.binarySearchR(i, t => (t < p)), N);
          debug {
            writeln(i, ": ", posL, " ", posR);
          }
          const res = segCnt[a].query(posL, posR);
          debug {
            writeln(i, ": ", posL, " ", posR, "; ", res);
          }
          ans += res;
        }
      }
      
      ans -= N;
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 77712