#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int n, m;
int main() {
  cin >> n >> m;
  map<int, bool> my;
  for (int i = 0; i < m; ++i) {
    int num;
    cin >> num;
    int res = num % n;
    if (my[res]) {
      cout << i + 1 << endl;
      return 0;
    }
    my[res] = 1;
  }
  puts("-1");
  return 0;
}
