#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, i;
  cin >> t;
  cin >> n;
  int x = 0;
  int a[305] = {0};
  long long b;
  int flag = -2;
  for (i = 0; i < n; i++) {
    cin >> b;
    if (a[b % t] == 0 && x == 0)
      a[b % t] = 1;
    else if (x == 0) {
      x = 1;
      flag = i;
    }
  }
  cout << flag + 1 << endl;
  return 0;
}
