#include <bits/stdc++.h>
using namespace std;
long long n, p, x, arr[400];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> p >> n;
  for (long long i = 0; i <= n - 1; i++) {
    cin >> x;
    if (arr[x % p]) {
      cout << i + 1 << endl;
      return 0;
    }
    arr[x % p]++;
  }
  cout << "-1" << endl;
  cin >> n;
  return 0;
}
