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