#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int i, n, t, j = 0, p, x, a = 0, b, l = 0, r = 0, y, k, c, sum = 0,
                         m, d, cnts = 0;
  cin >> p >> n;
  int ara[400] = {};
  l = 0;
  x = 0;
  while (n--) {
    l++;
    cin >> a;
    if (ara[a % p] == 1 && x == 0) {
      x = l;
    } else {
      ara[a % p] = 1;
    }
  }
  if (x)
    cout << x << endl;
  else
    cout << -1 << endl;
}
