#include <bits/stdc++.h>
using namespace std;
int r[305];
int main() {
  int p, n;
  cin >> p >> n;
  int a[n + 5];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int sum = 0, c = 0, f = -1;
  for (int i = 1; i <= n; i++) {
    c = a[i] % p;
    if (r[c] == 0) {
      f = -1;
      r[c]++;
    } else {
      f = i;
      break;
    }
  }
  cout << f << endl;
  return 0;
}
