#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 0, 1, 1, 1, 0, -1, -1}, dy[] = {-1, -1, -1, 0, 1, 1, 1, 0};
int cx[] = {1, 1, 2, 2, -1, -1, -2, -2}, cy[] = {2, -2, 1, -1, 2, -2, 1, -1};
template <class T>
int len(const T& c) {
  return (int)c.size();
}
long long stoi(string s) {
  long long n = 0;
  for (__typeof(len(s)) i = 0; i < (len(s)); i++)
    n = (n << 3) + (n << 1) + (s[i] - 48);
  return n;
}
string itos(long long n) {
  if (n == 0) return "0";
  string s;
  while (n) {
    s += (n % 10 + 48);
    n /= 10;
  }
  reverse((s).begin(), (s).end());
  return s;
}
int main() {
  ios_base::sync_with_stdio(false);
  long p, n;
  while (cin >> p >> n) {
    set<long> string;
    for (__typeof(n) i = 1; i <= (n); i++) {
      long a, b;
      b = string.size();
      cin >> a;
      string.insert(a % p);
      if (b == string.size()) {
        cout << i << endl;
        return 0;
      }
    }
    cout << -1 << endl;
  }
  return 0;
}
