#include <bits/stdc++.h>
using namespace std;
int main() {
  int p, n;
  vector<int> a;
  cin >> p >> n;
  for (int i = 0; i < p; i++) a.push_back(0);
  int temp;
  int ithelement = -1;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    if (a[temp % p] != 0 && ithelement == -1) ithelement = i;
    a[temp % p] = 1;
  }
  if (ithelement != -1)
    cout << ithelement + 1 << endl;
  else
    cout << ithelement << endl;
}
