#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 2;
int n;
long long A[MAX], H;
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> H >> n;
  long long sum = 0, u = 0, d = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> A[i];
    A[i] = -A[i];
    sum += A[i];
    u = max(u, sum);
    d = min(d, sum);
  }
  if (u < H && sum <= 0) {
    cout << -1;
    return 0;
  }
  long long k = (u >= H ? 0 : (H - u - 1) / sum + 1);
  long long ans = n * k, cur = k * sum;
  for (int i = 1; i <= n; ++i) {
    cur += A[i];
    ++ans;
    if (cur >= H) break;
  }
  cout << ans;
}
