P1695 [CF337E] Divisor Tree
提高+
题目描述

A divisor tree is a rooted tree that meets the following conditions:

  • Each vertex of the tree contains a positive integer number.
  • The numbers written in the leaves of the tree are prime numbers.
  • For any inner vertex, the number within it is equal to the product of the numbers written in its children.

Manao has n distinct integers a1, a2, ..., an. He tries to build a divisor tree which contains each of these numbers. That is, for each ai, there should be at least one vertex in the tree which contains ai. Manao loves compact style, but his trees are too large. Help Manao determine the minimum possible number of vertices in the divisor tree sought.

Input

The first line contains a single integer n (1 ≤ n ≤ 8). The second line contains n distinct space-separated integers ai (2 ≤ ai ≤ 1012).

Output

Print a single integer — the minimum number of vertices in the divisor tree that contains each of the numbers ai.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 6 10
样例输出
7
提示

Sample 1. The smallest divisor tree looks this way:

Sample 2. In this case you can build the following divisor tree:

Sample 3. Note that the tree can consist of a single vertex.