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