import java.util.*; public class Main { static BinaryIndexedTree bit; static ArrayList> graph = new ArrayList<>(); public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for (int i = 0; i < n; i++) { graph.add(new ArrayList<>()); } for (int i = 1; i < n; i++) { graph.get(sc.nextInt()).add(i); } bit = new BinaryIndexedTree(n + 1); System.out.println(search(0)); } static int search(int idx) { int sum = bit.getSum(idx + 1); bit.add(idx + 1, 1); for (int x : graph.get(idx)) { sum += search(x); } bit.add(idx + 1, -1); return sum; } } class BinaryIndexedTree { int size; int[] tree; public BinaryIndexedTree(int size) { this.size = size; tree = new int[size]; } public void add(int idx, int value) { int mask = 1; while (idx < size) { if ((idx & mask) != 0) { tree[idx] += value; idx += mask; } mask <<= 1; } } public int getSum(int from, int to) { return getSum(to) - getSum(from - 1); } public int getSum(int x) { int mask = 1; int ans = 0; while (x > 0) { if ((x & mask) != 0) { ans += tree[x]; x -= mask; } mask <<= 1; } return ans; } }