#include <bits/stdc++.h>
using namespace std;
std::map<int, bool> mp;
int main() {
  int n, p;
  scanf("%d%d", &p, &n);
  int ans = -1;
  bool is = true;
  for (int i = 0; i < n; i++) {
    int tmp;
    scanf("%d", &tmp);
    if (mp.find(tmp % p) != mp.end() && is) {
      ans = i + 1;
      is = false;
    }
    mp[tmp % p] = true;
  }
  printf("%d\n", ans);
  return 0;
}
