#include <bits/stdc++.h>
using namespace std;
int a[10000000];
int main() {
  int p, n;
  cin >> p >> n;
  int i, f1 = 0, note = -1;
  for (i = 0; i < n; i++) {
    int z;
    cin >> z;
    int x = z % p;
    if (a[x] == 0) {
      a[x] = 1;
    } else if (f1 == 0) {
      note = i + 1;
      f1 = 1;
    }
  }
  cout << note << endl;
  return 0;
}
