void solve() {
  ll n;
  cin >> n;
  ll a[n];
  ll f = 0;
  ll g = 0;
  f(i, n) {
    cin >> a[i];
    g = __gcd(g, a[i]);
    if (a[i] % 2 != 0 and a[i] % 3 != 0 and a[i] > 1) {
      f = 1;
    }
  }
  if (f == 1) {
    cout << -1 << endl;
    return;
  }
  ll cnt = 0;
  f(i, n) {
    ll x = a[i] / g;
    while (x % 3 == 0) {
      x = x / 3;
      cnt++;
    }
    while (x % 2 == 0) {
      x = x / 2;
      cnt++;
    }
  }
  cout << cnt << endl;
}