#include <bits/stdc++.h>
int main() {
  int p, n;
  int i, remainder;
  long int x;
  int table[302] = {0};
  scanf("%d %d", &p, &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &x);
    remainder = x % p;
    if (table[remainder] == 0) {
      table[remainder] = 1;
    } else {
      printf("%d\n", i + 1);
      return 0;
    }
  }
  printf("%d\n", -1);
  return 0;
}
