#include <bits/stdc++.h>
using namespace std;
inline int inp() {
  int n, ch;
  while ((ch = getchar()) < '0')
    ;
  n = (ch - '0');
  while ((ch = getchar()) >= '0') n = (n << 3) + (n << 1) + (ch - '0');
  return n;
}
short gcd(short a, short b) {
  while (a != 0) {
    unsigned long long int temp = a;
    a = b % a;
    b = temp;
  }
  return b;
}
int main() {
  int p = inp();
  int n = inp();
  bool check[p];
  for (int i = 0; i < p; i++) check[i] = false;
  for (int i = 0; i < n; i++) {
    int k = inp();
    if (check[k % p]) {
      printf("%d", i + 1);
      return 0;
    } else
      check[k % p] = true;
  }
  printf("-1");
  return 0;
}
