#include <bits/stdc++.h>
using namespace std;
long long d[200005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long h, n, sum = 0, m = 1e18;
  cin >> h >> n;
  for (long long i = 0; i < n; i++) {
    cin >> d[i];
    sum += d[i];
    m = min(m, sum);
  }
  m *= -1;
  long long p = 0;
  if (sum < 0) {
    long long r, sum1 = 0;
    sum *= -1;
    if (h <= m)
      r = 0;
    else {
      if ((h - m) % sum == 0)
        r = (h - m) / sum;
      else
        r = ((h - m) / sum) + 1;
    }
    h -= sum * r;
    for (long long i = 0; i < n; i++) {
      sum1 += d[i];
      if (h + sum1 <= 0) {
        p = i + 1;
        break;
      }
    }
    cout << r * n + p << endl;
    return 0;
  } else if (sum >= 0 && h - m <= 0) {
    long long sum1 = 0;
    for (long long i = 0; i < n; i++) {
      sum1 += d[i];
      if (h + sum1 <= 0) {
        p = i + 1;
        break;
      }
    }
    cout << p << endl;
    return 0;
  } else {
    cout << -1 << endl;
    return 0;
  }
  return 0;
}
