#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100100;
bool A[MAXN] = {0};
int N, M, x;
int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> x;
    if (A[x % N]) {
      cout << i + 1 << endl;
      return 0;
    }
    A[x % N] = true;
  }
  cout << -1 << endl;
  return 0;
}
