#include <bits/stdc++.h>
int main() {
  int vis[1000];
  memset(vis, 0, sizeof(vis));
  int p, n, i, x, flag = -1;
  scanf("%d %d", &p, &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &x);
    vis[x % p]++;
    if (vis[x % p] > 1 && flag == -1) flag = i;
  }
  printf("%d\n", flag);
  return 0;
}
