Code fails for large numbers(Number of divisors)

https://hack.codingblocks.com/contests/c/512/815
https://ide.codingblocks.com/s/40876

As the constraint are too large you cannot multiply the elements of array because of overflow .
So, think of the way of exponent of distinct prime divisors .
Apply the sieve for storing the prime factorization of each number less than 10^6+1.
So when you are iterating over the given array you will have its prime factorisation ,so,time complexity will decrease by large amount.
And in each iteration add the exponent of each prime factos of ai.
Finally you will have an array having distinct prime factors with its exponent.
You must know the way to calculate the number of divisors of the form (a1^q1)(a2^q2)…(an^qn) which is equal to (q1+1)(q2+1)…(qn+1)