#include <bits/stdc++.h>
using namespace std;
int const N = 1e6 + 3;
long long MOD = 1e9 + 7, fact[N];
const long long INF = (long long)1e18;
const long double PI = 3.14159265358979;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ;
  int p, n;
  cin >> p >> n;
  set<int> s;
  int ans = 0;
  int tmp = 0, flag = 0;
  while (n--) {
    int x;
    tmp++;
    cin >> x;
    if (s.find(x % p) != s.end() && flag == 0) {
      ans = tmp;
      flag = 1;
    } else {
      s.insert(x % p);
    }
  }
  if (ans == 0) {
    cout << -1 << '\n';
  } else {
    cout << ans << '\n';
  }
  return 0;
}
