#include<cstdio>
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
const int N = 10001;
bool hashtable[N] = { 0 };
bool isprime(int n) {
if (n <= 1) return false;
int sqr = sqrt(n);
for (int i = 2; i <= sqr; i++) {
if (n % i == 0)
return false;
}
return true;
}
int main()
{
int n, Tsize, a;
cin >> Tsize >> n;
while (isprime(Tsize) == false)
Tsize++;
for (int i = 0; i < n; i++)
{
cin >> a;
int M = a % Tsize;
if (hashtable[M] == false)
{
hashtable[M] = true;
if (i == 0) cout << M;
else cout << " " << M;
}
else
{
int step;
for (step = 1; step < Tsize; step++)
{
M = (a + step * step) % Tsize;
if (hashtable[M] == false)
{
hashtable[M] = true;
if (i == 0) cout << M;
else cout << " " << M;
break;
}
}
if (step == Tsize)
{
if (i > 0)
cout << " " << "-";
}
}
}
}