#include <bits/stdc++.h>
using namespace std;
long long H, S, d[600005], N, Ans;
int main() {
  cin >> H >> N;
  for (int i = 1; i <= N; i++) {
    cin >> d[i];
    d[i + N] = d[i];
    d[i + 2 * N] = d[i];
    S += d[i];
  }
  if (S >= 0) {
    for (int i = 1; i <= N; i++) {
      H += d[i];
      if (H <= 0) {
        cout << i;
        return 0;
      }
    }
    cout << -1;
  } else {
    int p = 0;
    long long Min = H, Q = H;
    for (int i = 1; i <= N; i++) {
      Q += d[i];
      if (Q <= 0) {
        cout << i;
        return 0;
      }
      if (Min > Q) p = i, Min = Q;
    }
    H = Min;
    Ans += p;
    S *= -1;
    Ans += N * max(0LL, (H / S) - 1);
    H -= max(0LL, (H / S) - 1) * S;
    p++;
    while (H) {
      H += d[p];
      Ans++;
      p++;
      if (H <= 0) {
        cout << Ans;
        return 0;
      }
    }
  }
  return 0;
}
