#include <bits/stdc++.h>
using namespace std;
long long powermodm(long long x, long long n, long long M) {
  long long result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = (result * x) % M;
    x = (x * x) % M;
    n = n / 2;
  }
  return result;
}
long long power(long long _a, long long _b) {
  long long _r = 1;
  while (_b) {
    if (_b % 2 == 1) _r = (_r * _a);
    _b /= 2;
    _a = (_a * _a);
  }
  return _r;
}
void build() {}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  build();
  long long H, n;
  cin >> H >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long sum[n], mn = LONG_LONG_MAX;
  mn = sum[0] = a[0];
  if (sum[0] + H <= 0) {
    cout << 1;
    return 0;
  }
  for (long long i = 1; i < n; i++) {
    sum[i] = sum[i - 1] + a[i];
    mn = min(mn, sum[i]);
    if (sum[i] + H <= 0) {
      cout << i + 1;
      return 0;
    }
  }
  if (sum[n - 1] >= 0) {
    cout << -1;
    return 0;
  }
  H += mn;
  long long x = H / (long long)abs(sum[n - 1]);
  H -= x * (long long)abs(sum[n - 1]);
  H -= mn;
  for (long long i = 0; i < n; i++) {
    if (H + sum[i] <= 0) {
      cout << x * n + i + 1;
      return 0;
    }
  }
  H -= (long long)abs(sum[n - 1]);
  for (long long i = 0; i < n; i++) {
    if (H + sum[i] <= 0) {
      cout << (x + 1) * n + i + 1;
      return 0;
    }
  }
  return 0;
}
