#include <bits/stdc++.h>
using namespace std;
int af[310];
int main() {
  int m, n;
  cin >> m >> n;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    int tt = t % m;
    af[tt]++;
    if (af[tt] > 1) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}
