#include <bits/stdc++.h>
using namespace std;
int main() {
  int p, n, i, t = 0;
  cin >> p >> n;
  int a[n];
  set<int, greater<int> > s1;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n; i++) {
    s1.insert(a[i] % p);
    if (s1.size() != i + 1) {
      cout << i + 1;
      t = 1;
      break;
    }
  }
  if (t == 0) cout << -1;
}
