#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.1415926535897932384626433832795l;
template <typename T>
inline auto sqr(T x) -> decltype(x * x) {
  return x * x;
}
template <typename T1, typename T2>
inline bool umx(T1& a, T2 b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
inline bool umn(T1& a, T2 b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const int N = 1000000;
const int M = 50;
struct Input {
  int n, m;
  int a[2 * N];
  long long b[M];
  bool read() {
    if (!(cin >> n >> m)) {
      return 0;
    }
    for (int i = int(0); i < int(n); ++i) {
      scanf("%d", &a[i]);
    }
    for (int i = int(0); i < int(m); ++i) {
      cin >> b[i];
    }
    return 1;
  }
  void init(const Input& input) { *this = input; }
};
struct Data : Input {
  int ans[M];
  void write() {
    for (int i = int(0); i < int(m); ++i) {
      cout << ans[i] << endl;
    }
  }
  virtual void solve() {}
  virtual void clear() { *this = Data(); }
};
struct Solution : Data {
  int go[2 * N + 1];
  int b[N + 1];
  void solve() {
    memcpy(a + n, a, n * sizeof(int));
    for (int t = int(0); t < int(m); ++t) {
      {
        long long s = 0;
        int r = 2 * n;
        go[r] = r;
        for (int l = int(2 * n) - 1; l >= int(0); --l) {
          s += a[l];
          while (s > Data::b[t]) {
            --r;
            s -= a[r];
          }
          go[l] = r;
        }
      }
      b[0] = 0;
      ans[t] = 0;
      while (b[ans[t]] < n) {
        b[ans[t] + 1] = go[b[ans[t]]];
        ans[t]++;
      }
      if (ans[t] == 1) {
        continue;
      }
      int bst = 0, mn = n;
      for (int i = int(0); i < int(ans[t] - 1); ++i) {
        if (umn(mn, b[i + 1] - b[i])) {
          bst = i;
        }
      }
      for (int i = int(b[bst]); i < int(b[bst + 1] + 1); ++i) {
        int pos = i;
        for (int j = int(0); j < int(ans[t] - 1); ++j) {
          pos = go[pos];
        }
        if (pos >= i + n) {
          ans[t]--;
          break;
        }
      }
    }
  }
  void clear() { *this = Solution(); }
};
Solution sol;
int main() {
  cout.setf(ios::showpoint | ios::fixed);
  cout.precision(20);
  sol.read();
  sol.solve();
  sol.write();
  return 0;
}
