using System;
using CompLib.Collections;
using CompLib.Util;

public class Program
{
    private int N;
    private string[] S;
    private const long Mod1 = 1000000007;
    private const long Mod2 = (119 << 23) + 1;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        S = new string[N];
        for (int i = 0; i < N; i++)
        {
            S[i] = sc.Next();
        }

        Array.Sort(S, (l, r) => l.Length.CompareTo(r.Length));

        // 1文字+のこり

        // 末尾 + 
        // 末尾が一致してる + 以前一致1文字
        // 

        var map = new HashMap<(long h1, long h2, int len), int>();
        long ans = 0;
        foreach (var t in S)
        {
            // tの末尾のハッシュ値
            long h1 = 0;
            long h2 = 0;
            int[] cnt = new int[26];
            for (int i = 0; i < t.Length; i++)
            {
                h1 *= 26;
                h2 *= 26;
                h1 += t[i] - 'a';
                h2 += t[i] - 'a';
                h1 %= Mod1;
                h2 %= Mod2;
                cnt[t[i] - 'a']++;
            }


            long p1 = 1;
            long p2 = 1;
            long i1 = 0;
            long i2 = 0;
            for (int i = 0; i < t.Length; i++)
            {
                int j = t.Length - i - 1;
                for (int c = 0; c < 26; c++)
                {
                    if (cnt[c] == 0) continue;
                    long hh1 = (i1 + p1 * c) % Mod1;
                    long hh2 = (i2 + p2 * c) % Mod2;
                    ans += map[(hh1, hh2, i)];
                }

                cnt[t[j] - 'a']--;
                i1 += (t[j] - 'a') * p1;
                i1 %= Mod1;
                i2 += (t[j] - 'a') * p2;
                i2 %= Mod2;
                p1 *= 26;
                p1 %= Mod1;
                p2 *= 26;
                p2 %= Mod2;
            }

            map[(h1, h2, t.Length - 1)]++;
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Collections
{
    using System.Collections.Generic;

    public class HashMap<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get
            {
                TValue o;
                return TryGetValue(key, out o) ? o : default(TValue);
            }
            set { base[key] = value; }
        }
    }
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 69664