#include <bits/stdc++.h>
using namespace std;
int mod1 = 998244353;
long long int sum[200005], h, num;
int n;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> h >> n;
  long long int m = -1e12;
  for (int i = 1; i <= n; i++) {
    cin >> num;
    sum[i] = sum[i - 1] - num;
    m = max(m, sum[i]);
  }
  long long int ans = 0;
  if (h > m) {
    if (sum[n] <= 0) {
      cout << -1;
      return 0;
    }
    ans = ((h - m) / sum[n]);
    if ((h - m) % sum[n] != 0) ans++;
    h -= (ans * sum[n]);
    ans = ans * n;
  }
  for (int i = 1; i <= n; i++) {
    if (h <= sum[i]) {
      ans += i;
      break;
    }
  }
  cout << ans;
  return 0;
}
