#include <bits/stdc++.h>
using namespace std;
int main() {
  map<int, int> mp;
  int p, n, f = 1, x, ans = -1;
  cin >> p >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    if (f and mp.find(x % p) != mp.end()) {
      ans = i;
      f = 0;
    }
    mp[x % p] = x;
  }
  cout << ans;
  return 0;
}
