#include <bits/stdc++.h>
int Haxi[305];
long long num[305];
int main() {
  int n, p, i, tmp, k = -1;
  scanf("%d%d", &p, &n);
  for (i = 0; i < p; i++) Haxi[i] = 0;
  for (i = 0; i < n; i++) scanf("%I64d", num + i);
  for (i = 0; i < n; i++) {
    tmp = num[i] % p;
    if (Haxi[tmp]) {
      k = tmp;
      break;
    } else
      ++Haxi[tmp];
  }
  if (k != -1) k = i + 1;
  printf("%d\n", k);
  return 0;
}
