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