#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int64_t n, i, j, k, o = 0, w = 0;
  int64_t p;
  cin >> p >> n;
  int64_t a[n];
  int64_t b[p];
  for (i = 0; i < p; i++) b[i] = 0;
  int64_t s = 0;
  for (i = 0; i < n; i++) {
    cin >> k;
    w = k % p;
    if (b[w] != 0 && o == 0) {
      o = s + 1;
    }
    s++;
    b[w] = 1;
  }
  if (o == 0)
    cout << -1;
  else
    cout << o;
  return 0;
}
