#include <bits/stdc++.h>
using namespace std;
bool ALL[305], done = 0;
int input[305], n, t, p, ANS = -1;
int main() {
  memset(ALL, 0, sizeof ALL);
  cin >> p >> n;
  for (int i = 1; i <= n; i++) {
    cin >> t;
    if (ALL[t % p] && !done) {
      ANS = i;
      done = 1;
    } else
      ALL[t % p] = 1;
  }
  cout << ANS;
  return 0;
}
