#include <bits/stdc++.h>
using namespace std;
int main() {
  int p[301] = {0}, n, rem, m;
  long long int x;
  cin >> m >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    rem = x % m;
    p[rem]++;
    if (p[rem] > 1) {
      cout << i + 1;
      return 0;
    }
  }
  cout << -1;
}
