#include <bits/stdc++.h>
using namespace std;
int64_t v[200005] = {0};
int64_t fnc(int64_t h, int n) {
  int64_t mn = v[0];
  for (int i = 1; i < n; i++) {
    v[i] += v[i - 1];
    mn = min(mn, v[i]);
  }
  if (v[n - 1] >= 0 && h + mn > 0) return -1;
  int64_t ans = 0;
  if (h + mn <= 0) {
    for (int i = 0; i < n; i++)
      if (h + v[i] <= 0) return i + 1;
  }
  int64_t t = ceil(((-mn - h) * 1.0) / v[n - 1]);
  if (t < 0) t = 0;
  ans += n * t;
  h = h + t * v[n - 1];
  for (int i = 0; i < n; i++) {
    if (h + v[i] <= 0) {
      ans += i + 1;
      break;
    }
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int m;
  int64_t h;
  cin >> h >> m;
  for (int i = 0; i < m; i++) cin >> v[i];
  cout << fnc(h, m) << endl;
  return 0;
}
