#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  int p, n;
  cin >> p >> n;
  bool table[300];
  memset(table, 0, sizeof(bool) * 300);
  int ans = -1;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    int hash = tmp % p;
    if (table[hash] != 0) {
      ans = i + 1;
      break;
    } else {
      table[hash] = 1;
    }
  }
  cout << ans << endl;
}
