using System;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System.Collections.Generic;

class Myon

{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }
    static Scanner cin;

    class Node
    {
        public Node[] Next;
        public bool exist;
        public Node() {
            Next = new Node[26];
        }
    }



    void calc()
    {
        int N = cin.nextInt();
        string[] S = new string[N];
        for (int i = 0; i < N; i++)
        {
            S[i] = cin.next();
        }
        IComparer<string> strlenComp = new StrLenComparer();
        Array.Sort(S, strlenComp);

        Node FirstNode = new Node();

        long ans = 0;

        for (int i = 0; i < N; i++)
        {
            Node NowNode = FirstNode;
            int[] num = new int[26];
            bool active = true;

            foreach(var c in S[i])
            {
                num[c - 'a']++;
            }

            for (int j = S[i].Length - 1; j >= 0; j--)
            {
                if (active)
                {
                    for (int k = 0; k < 26; k++)
                    {
                        if (num[k] == 0) continue;
                        if (NowNode.Next[k] != null && NowNode.Next[k].exist) ans++; 
                    }
                }
                char c = S[i][j];
                int p = c - 'a';
                num[p]--;
                if(NowNode.Next[p] == null)
                {
                    active = false;
                    NowNode.Next[p] = new Node();
                }
                NowNode = NowNode.Next[p];

            }
            NowNode.exist = true;
        }


        Console.WriteLine(ans);

    }

    public class StrLenComparer : IComparer<string>
    {
        public int Compare(string x, string y)
        {
            return x.Length - y.Length;
        }
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 290368