#include <bits/stdc++.h>
using namespace std;
const int max_N = 100010;
int a[max_N];
int b[max_N];
int main() {
  int P, N;
  cin >> P >> N;
  for (int i = 0; i < max_N; i++) a[i] = b[i] = 0;
  for (int i = 0; i < N; i++) cin >> a[i];
  for (int i = 0; i < N; i++) {
    int r = a[i] % P;
    if (b[r] == 0) {
      b[r]++;
    } else {
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
