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