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