#include <bits/stdc++.h>
using namespace std;
bool ok[305];
int p, n, i, l, a;
int main() {
  cin >> p >> n;
  l = -1;
  for (i = 1; i <= n; i++) {
    cin >> a;
    if (ok[a % p] == false)
      ok[a % p] = true;
    else if (l == -1)
      l = i;
  }
  cout << l;
  return 0;
}
