#include <bits/stdc++.h>
int main() {
  long long int n, p, i, j, coun = 0, count[300];
  scanf("%lld %lld", &p, &n);
  long long int a[n + 1];
  for (i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  for (i = 0; i < 300; i++) {
    count[i] = 0;
  }
  for (i = 1; i <= n; i++) {
    if (count[a[i] % p] == 0)
      count[a[i] % p]++;
    else {
      printf("%lld\n", i);
      coun++;
      break;
    }
  }
  if (coun == 0) printf("-1\n");
  return 0;
}
