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