#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
using namespace std;
long long dp[maxn], sum[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, h;
  while (cin >> h >> n) {
    for (int i = 1; i <= n; ++i) {
      cin >> dp[i];
      sum[i] = dp[i] + sum[i - 1];
    }
    long long ans = 1e18;
    for (long long i = 1; i <= n; ++i) {
      long long last = h + sum[i];
      if (last <= 0) {
        ans = min(ans, i);
      } else {
        if (sum[n] >= 0) continue;
        long long cnt = last / (abs(sum[n]));
        if (last % abs(sum[n])) cnt++;
        ans = min(ans, cnt * n + i);
      }
    }
    ans = (ans == 1e18) ? -1 : ans;
    cout << ans << endl;
  }
  return 0;
}
