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