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