#include <bits/stdc++.h>
int i, j;
using namespace std;
int main() {
  vector<long long> v(100000, 0);
  vector<long long> ar;
  int p, n, m = 11111110;
  cin >> p >> n;
  for (i = 0; i < n; i++) cin >> v[i];
  for (i = 0; i < n; i++) {
    long long x;
    x = v[i] % p;
    ar.push_back(x);
  }
  int c = 0, t = 1, k;
  for (i = 0; i < n - 1; i++) {
    for (j = i + 1; j < n; j++) {
      if (ar[i] == ar[j]) {
        k = j + 1;
        m = min(k, m);
        c++;
        t = 0;
      }
    }
  }
  if (c == 0)
    cout << "-1\n";
  else
    cout << m << endl;
}
