#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long p, n;
  cin >> p >> n;
  long long hx;
  set<long long> set1;
  bool k = false;
  long long arr[n];
  int q;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      hx = (arr[i] % p);
      set1.insert(hx);
    } else {
      hx = (arr[i] % p);
      if (set1.count(hx)) {
        cout << i + 1 << endl;
        return 0;
      } else
        set1.insert(hx);
    }
  }
  cout << -1 << endl;
  return 0;
}
