#include <bits/stdc++.h>
using namespace std;
void solve() {
  map<int, int> mp;
  int x, y;
  cin >> x >> y;
  for (int i = 1; i <= y; ++i) {
    int cur;
    cin >> cur;
    if (!mp[cur % x])
      ++mp[cur % x];
    else {
      cout << i << endl;
      return;
    }
  }
  cout << -1 << endl;
  return;
}
int main() {
  int t = 1;
  while (t--) solve();
  return 0;
}
