#include <bits/stdc++.h>
using namespace std;
const int oo = int(2e9) + 9;
const double eps = 1e-9;
const double pi = 3.14159265358979323846264338327950;
int main() {
  int p, n;
  int a[305];
  scanf("%d %d", &p, &n);
  memset(a, -1, sizeof(a));
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    if (a[x % p] != -1) {
      printf("%d\n", i);
      return 0;
    }
    a[x % p] = 1;
  }
  printf("-1\n");
  return 0;
}
