#include <bits/stdc++.h>
int main() {
  int p, n, x, arr[301] = {0};
  int ret = 0;
  scanf("%d %d", &p, &n);
  for (int ii = 0; ii < n; ii++) {
    scanf("%d", &x);
    if (arr[x % p] && !ret) {
      ret = ii + 1;
    }
    arr[x % p] = 1;
  }
  printf("%d\n", ret ? ret : -1);
  return 0;
}
