const N: usize = 26;
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let mut trie = Trie {
        nodes: vec![Node::new()],
    };
    let n: usize = sc.read();
    let mut ss = vec![];
    for _ in 0..n {
        let s = sc
            .read::<String>()
            .chars()
            .rev()
            .map(|c| c as usize - 'a' as usize)
            .collect::<Vec<usize>>();
        let mut count = [0; N];
        for &c in s.iter() {
            count[c] += 1;
        }
        trie.insert(0, &s, 0, &mut count);
        ss.push(s);
    }

    let mut ans = 0;
    for s in ss.iter() {
        let count = trie.get(0, s, 0);
        assert!(count >= 1);
        ans += count - 1;
        // eprintln!("count={}", count);
    }
    println!("{}", ans);
}

struct Trie {
    nodes: Vec<Node>,
}

impl Trie {
    fn insert(&mut self, node_id: usize, s: &[usize], pos: usize, count: &mut [usize]) {
        for i in 0..N {
            if count[i] > 0 {
                self.nodes[node_id].one_char_count[i] += 1;
            }
        }
        if s.len() == pos {
            return;
        }

        let c = s[pos];
        let next_id = if self.nodes[node_id].children[c] == 0 {
            let next_id = self.nodes.len();
            self.nodes.push(Node::new());
            self.nodes[node_id].children[c] = next_id;
            next_id
        } else {
            self.nodes[node_id].children[c]
        };

        count[c] -= 1;
        self.insert(next_id, s, pos + 1, count);
    }

    fn get(&self, node_id: usize, s: &[usize], pos: usize) -> usize {
        if pos == s.len() - 1 {
            let last_c = s[pos];
            return self.nodes[node_id].one_char_count[last_c];
        }

        let next_c = s[pos];
        let next_id = self.nodes[node_id].children[next_c];
        assert_ne!(next_id, 0);
        self.get(next_id, s, pos + 1)
    }
}

struct Node {
    children: [usize; N],
    one_char_count: [usize; N],
}

impl Node {
    fn new() -> Self {
        Self {
            children: [0; 26],
            one_char_count: [0; 26],
        }
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write_all(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 415704