#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, p, a[301] = {0};
  ;
  bool b[301] = {0}, f = 0;
  cin >> p >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    if (b[a[i] % p]) {
      cout << i;
      f = 1;
      break;
    } else
      b[a[i] % p] = 1;
  }
  if (!f) cout << -1;
  return 0;
}
