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