#include <bits/stdc++.h>
using namespace std;
const int mn = 2e5 + 10;
const long long inf = 1e18;
long long d[mn], sum[mn];
int main() {
  long long h;
  int n;
  cin >> h >> n;
  for (int i = 1; i <= n; i++) cin >> d[i];
  long long minn = inf;
  for (int i = 1; i <= n; i++) {
    sum[i] = sum[i - 1] + d[i];
    minn = min(minn, sum[i]);
  }
  if (h + minn > 0 && sum[n] >= 0) {
    cout << -1 << endl;
    return 0;
  }
  if (h + minn <= 0) {
    for (int i = 1; i <= n; i++) {
      if (h + sum[i] <= 0) {
        cout << i << endl;
        break;
      }
    }
  } else {
    long long ans = 0;
    long long temp = h + minn;
    long long summ = -sum[n];
    if (temp % summ == 0) {
      ans += temp / summ * n;
      h -= temp;
    } else {
      ans += (temp / summ + 1) * n;
      h -= (temp / summ + 1) * summ;
    }
    for (int i = 1; i <= n; i++) {
      h += d[i];
      ans++;
      if (h <= 0) {
        cout << ans << endl;
        break;
      }
    }
  }
  return 0;
}
