using System;
class Program
{
    static int Deli(int n)
    {
        int rez = n + 1;
        for(int i = 2; i <= n/2; i++)
            if(n % i == 0)
                rez += i;
        if(rez % 2 == 0)
            return rez/2;
        else
            return rez;
    }
    static void Main()
    {
        string[] s = Console.ReadLine().Split();
        int n = int.Parse(s[0]);
        int k = int.Parse(s[1]);
        int[] d = new int[k];
        s = Console.ReadLine().Split();
        for (int i = 0; i < k; i++)
        {
            d[i] = int.Parse(s[i]);
            Console.Write(Deli(d[i]) + " ");
        }
    }
}