#include <bits/stdc++.h>
using namespace std;
int main() {
  iostream::sync_with_stdio(false);
  ;
  int p, n;
  vector<int> v;
  cin >> p >> n;
  int ultimo = 0, saida = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (!binary_search(v.begin(), v.end(), x % p)) {
      v.push_back(x % p);
      sort(v.begin(), v.end());
    } else {
      if (!ultimo) {
        saida = i;
      }
      ultimo = 1;
    }
  }
  cout << (ultimo ? saida + 1 : -1) << endl;
  return 0;
}
