Condition is that ai <= 10^9 .Im thinking of a brute force approach where i test every n form 1 to 10^9, but it would be way too heavy to run, are there any other way to