#include <bits/stdc++.h>
using namespace std;
int main() {
  int p, n, f = -1;
  cin >> p >> n;
  int a[p], x, i;
  memset(a, 0, sizeof(a));
  for (i = 0; i < n; i++) {
    cin >> x;
    if (a[x % p] && f == -1)
      f = i + 1;
    else
      a[x % p] = 1;
  }
  cout << f << endl;
  return 0;
}
