#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long p, n;
  cin >> p >> n;
  long output = -1;
  vector<bool> taken(p, 0);
  for (int i = 1; i <= n; i++) {
    long x;
    cin >> x;
    if (taken[x % p]) {
      output = i;
      break;
    } else
      taken[x % p] = 1;
  }
  cout << output;
  return 0;
}
