#include <bits/stdc++.h>
using namespace std;
bool shuzu[400];
int main() {
  bool hashash = 0;
  memset(shuzu, 0, sizeof(shuzu));
  int p, n;
  cin >> p >> n;
  for (int i = 1; i <= n; i++) {
    int num;
    cin >> num;
    num %= p;
    if (shuzu[num] == 1) {
      cout << i << endl;
      return 0;
    } else {
      shuzu[num] = 1;
    }
  }
  cout << -1 << endl;
  return 0;
}
