#include <iostream>
#include "math.h"
using namespace std;

int sum(long long a) {
    int sum1 = 0;
    while(a>0) {
        sum1 += a%10;
        a = a/10;
    }
    return sum1;
}

int sum_prost(long long a) {
    long long sum1 = 0;
    long long a1 = a;
    for (long long i = 2; i <= a; i++) {
        if (i == a1) return 0;
        if (a%i == 0) {
            sum1 += sum(i);
            a/=i;
            i--;
        }
    }
    return sum1;
}

int main()
{
    long long n,a[20],res[20],k=0;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
        k = a[i] + 1;
        while(sum(k) != sum_prost(k)) k++;
        res[i] = k;
    }
    for (int i = 0; i < n; i++) cout << res[i] << ' ';
    return 0;
}
