#include <bits/stdc++.h>
using namespace std;
int a[301];
int main() {
  int p, x, n, ans, i;
  int flag = 1, c = -1;
  cin >> p >> n;
  for (i = 0; i < n; i++) {
    cin >> x;
    ans = x % p;
    if (a[ans] != 0 && flag == 1) {
      c = i + 1;
      flag = 0;
    }
    a[ans] = 1;
  }
  cout << c << endl;
  return 0;
}
