#include <bits/stdc++.h>
using namespace std;
bool table[301];
int main() {
  int p, n, ans = -1, x;
  cin >> p >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (table[x % p] && ans == -1) {
      ans = i + 1;
    } else {
      table[x % p] = true;
    }
  }
  cout << ans << endl;
}
