Can someone please explain how to solve the problem http://codeforces.com/problemset/problem/453/B I am unable to understand even the editorials here http://codeforces.com/blog/entry/13190 that how not taking the factors of given array a[i] will minimise the expression like in editorials and operation is done to remove the prime factors of a[i] using bitmask.Also I wasn;t able to understand the dp part.So a detailed explanation will be highly appreciated. Thanks in advance.

a person who know bitmasks & dp well can undrestand the solotion whit this hints... i think you nedd to know more of Dp ans Bitmask :D

Ok I agree that i don;t know DP+bitmasks ! Would you suggest something to learn it except Topcoder I have tried but didn;t get much idea !

http://activities.tjhsst.edu/sct/lectures.php

Read about dp solution of travel salesman problem