#include <bits/stdc++.h>
using namespace std;
int arr[1000];
int main() {
  int n, p, i;
  cin >> n >> p;
  int a, flag = 1, g;
  for (i = 0; i < p; ++i) {
    cin >> a;
    g = a % n;
    if (arr[g] == 0)
      arr[g]++;
    else {
      flag = 0;
      cout << i + 1;
      break;
    }
  }
  if (flag == 1) cout << "-1";
}
