#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(0);
  int p, n, a[300], x = -1;
  double b[300] = {0};
  cin >> p >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    if (b[a[i] % p] != 0) {
      x = i + 1;
      break;
    } else
      b[a[i] % p]++;
  }
  cout << x << endl;
}
