#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, i, n, k, p, flat = -1;
  int sta[305] = {0};
  cin >> p >> n;
  for (i = 1; i <= n; i++) {
    cin >> a;
    a = a % p;
    if (sta[a] == 0)
      sta[a] = 1;
    else if (flat == -1) {
      flat = i;
    }
  }
  cout << flat << endl;
  return 0;
}
