#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long h, n;
  cin >> h >> n;
  vector<long long> d(n);
  for (int i = 0; i < n; ++i) cin >> d[i];
  vector<long long> prefSum(n);
  prefSum[0] = d[0];
  if (h + prefSum[0] <= 0) return cout << 1 << '\n', 0;
  for (int i = 1; i < n; ++i) {
    prefSum[i] = d[i] + prefSum[i - 1];
    if (h + prefSum[i] <= 0) return cout << i + 1 << '\n', 0;
  }
  long long mn = prefSum[0];
  for (int i = 1; i < n; ++i) mn = min(prefSum[i], mn);
  if (prefSum[n - 1] >= 0) return cout << -1 << '\n', 0;
  long long val = abs(h / prefSum[n - 1]) + 1;
  while (val > 0 && h + (val - 1) * prefSum[n - 1] + mn <= 0) --val;
  long long answer = val * n;
  h += val * prefSum[n - 1];
  for (int i = 0; i < n; ++i) {
    if (h + prefSum[i] <= 0) {
      return cout << answer + i + 1 << '\n', 0;
    }
  }
}
