#include <bits/stdc++.h>
using namespace std;
int has[305], b[305];
int n, p;
int main() {
  while (scanf("%d %d", &p, &n) != EOF) {
    int i, a;
    memset(has, -1, sizeof(has));
    for (i = 0; i < n; i++) scanf("%d", &b[i]);
    int fg = 1;
    for (i = 0; i < n; i++) {
      a = b[i];
      if (has[a % p] != -1) {
        printf("%d\n", i + 1);
        fg = 0;
        break;
      } else
        has[a % p] = a;
    }
    if (fg) printf("-1\n");
  }
  return 0;
}
