{"raw_statement":[{"iden":"problem statement","content":"You are given a sequence of positive integers: $A=(a_1,a_2,\\ldots,a_N)$.  \nYou can choose and perform one of the following operations any number of times, possibly zero.\n\n*   Choose an integer $i$ such that $1 \\leq i \\leq N$ and $a_i$ is a multiple of $2$, and replace $a_i$ with $\\frac{a_i}{2}$.\n*   Choose an integer $i$ such that $1 \\leq i \\leq N$ and $a_i$ is a multiple of $3$, and replace $a_i$ with $\\frac{a_i}{3}$.\n\nYour objective is to make $A$ satisfy $a_1=a_2=\\ldots=a_N$.  \nFind the minimum total number of times you need to perform an operation to achieve the objective. If there is no way to achieve the objective, print `-1` instead."},{"iden":"constraints","content":"*   $2 \\leq N \\leq 1000$\n*   $1 \\leq a_i \\leq 10^9$\n*   All values in the input are integers."},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$N$\n$a_1$ $a_2$ $\\ldots$ $a_N$"},{"iden":"sample input 1","content":"3\n1 4 3"},{"iden":"sample output 1","content":"3\n\nHere is a way to achieve the objective in three operations, which is the minimum needed.\n\n*   Choose an integer $i=2$ such that $a_i$ is a multiple of $2$, and replace $a_2$ with $\\frac{a_2}{2}$. $A$ becomes $(1,2,3)$.\n*   Choose an integer $i=2$ such that $a_i$ is a multiple of $2$, and replace $a_2$ with $\\frac{a_2}{2}$. $A$ becomes $(1,1,3)$.\n*   Choose an integer $i=3$ such that $a_i$ is a multiple of $3$, and replace $a_3$ with $\\frac{a_3}{3}$. $A$ becomes $(1,1,1)$."},{"iden":"sample input 2","content":"3\n2 7 6"},{"iden":"sample output 2","content":"\\-1\n\nThere is no way to achieve the objective."},{"iden":"sample input 3","content":"6\n1 1 1 1 1 1"},{"iden":"sample output 3","content":"0"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}