#include <bits/stdc++.h>
using namespace std;
int nextInt() {
  int res;
  assert(cin >> res);
  return res;
}
const int P = 300;
bool contain[P];
int main() {
  ios::sync_with_stdio(false);
  int p = nextInt();
  int n = nextInt();
  for (int i = 0; i < n; ++i) {
    int x = nextInt();
    if (contain[x % p]) {
      cout << i + 1;
      return 0;
    }
    contain[x % p] = true;
  }
  cout << -1;
  return 0;
}
