#include <bits/stdc++.h>
using namespace std;
int main() {
  long long h, n, mi = 0;
  cin >> h >> n;
  long long a[n], b[n + 1];
  b[0] = 0;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    b[i] = b[i - 1] + a[i - 1];
    if ((0 - b[i]) >= h) {
      cout << i;
      return 0;
    }
    if (b[i] < mi) mi = b[i];
  }
  if (b[n] >= 0) {
    cout << -1;
    return 0;
  }
  h += mi;
  long long kol = h / abs(b[n]);
  if (h % abs(b[n]) != 0) kol++;
  h = h + (b[n] * kol);
  h -= mi;
  for (int i = 1; i <= n; i++) {
    if ((0 - b[i]) >= h) {
      cout << i + kol * n;
      return 0;
    }
  }
}
