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