#include <bits/stdc++.h>
using namespace std;
map<int, bool> mp;
int main() {
  int p, n;
  scanf("%d%d", &p, &n);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int t;
    scanf("%d", &t);
    if (ans) continue;
    if (mp[t % p]) {
      ans = i;
    }
    mp[t % p] = 1;
  }
  printf("%d\n", ans == 0 ? -1 : ans);
  return 0;
}
