#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int h, n, s = 0, a;
  long long int cum[200010];
  long long int it;
  cin >> h >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (i > 0)
      cum[i] = cum[i - 1] + a;
    else
      cum[i] = a;
    s += a;
  }
  if (*min_element(cum, cum + n) + h > 0 && s >= 0)
    cout << -1 << endl;
  else {
    if (s != 0) {
      it = max(0ll, (h - abs(*min_element(cum, cum + n)))) / abs(s);
      it += min(1ll, max(0ll, (h - abs(*min_element(cum, cum + n)))) % abs(s));
    } else
      it = 0;
    h += it * s;
    it = n * it;
    for (int i = 0; i < n; i++) {
      it++;
      if (h + cum[i] <= 0) break;
    }
    cout << it << endl;
  }
  return 0;
}
