#include <bits/stdc++.h>
using namespace std;
int p, n, x, k, h[305], a[305];
int main(void) {
  scanf("%d%d", &p, &n);
  k = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &x);
    h[i] = x % p;
    for (int j = 1; j < i; ++j)
      if (h[j] == h[i]) a[k++] = i;
  }
  if (k != 0)
    printf("%d\n", a[0]);
  else
    printf("-1\n");
  return 0;
}
