Problem:
Score : 1400 points

Problem Statement

Snuke got an integer sequence from his mother, as a birthday present. The sequence has N elements, and the i-th of them is i.
Snuke performs the following Q operations on this sequence. The i-th operation, described by a parameter q_i, is as follows:

Take the first q_i elements from the sequence obtained by concatenating infinitely many copy of the current sequence, then replace the current sequence with those q_i elements.

After these Q operations, find how many times each of the integers 1 through N appears in the final sequence.

Constraints

1 ≦ N ≦ 10^5

0 ≦ Q ≦ 10^5

1 ≦ q_i ≦ 10^{18}

All input values are integers.

Input

The input is given from Standard Input in the following format:

N Q
q_1
:
q_Q

Output

Print N lines. The i-th line (1 ≦ i ≦ N) should contain the number of times integer i appears in the final sequence after the Q operations.

Sample Input 1

5 3
6
4
11

Sample Output 1

3
3
3
2
0

After the first operation, the sequence becomes: 1,2,3,4,5,1.

After the second operation, the sequence becomes: 1,2,3,4.

After the third operation, the sequence becomes: 1,2,3,4,1,2,3,4,1,2,3.

In this sequence, integers 1,2,3,4,5 appear 3,3,3,2,0 times, respectively.

Sample Input 2

10 10
9
13
18
8
10
10
9
19
22
27

Sample Output 2

7
4
4
3
3
2
2
2
0
0

Solution in C++14 (GCC 5.4.1) (judge verdict: Runtime Error)

#define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
#define lint long long
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#ifndef STOPIT
#define debug(...)\
  std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;
#else
#define debug 0;
#endif

template < typename Container,
  typename Value = typename Container::value_type,
  std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr
>
std::istream& operator>> (std::istream& is, Container& v) {
  for (auto & x : v) is >> x;
  return is;
}

template < typename Container,
  typename Value = typename Container::value_type,
  std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr
>
std::ostream& operator<< (std::ostream& os, Container const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

template <typename T, typename U>
std::ostream& operator<< (std::ostream& os, const std::pair<T, U>& pair)
  { return os << "(" << pair.first << "," << pair.second << ")"; }

template <typename T, typename U>
std::istream& operator>> (std::iostream& is, std::pair<T, U>& pair)
  { return is >> pair.first >> pair.second; }

int n;
std::vector< lint > a;

auto f(lint x) {
  auto lb = std::lower_bound(all(a), x);
  assert(lb != a.end());
  auto ret = std::map< int, lint >{};
  if (lb == a.begin()) {
    if (x > 0)
      { ret.emplace(x, 1); };
    return ret;
  }
  auto y = *std::prev(lb);
  auto q = x / y;
  auto r = x % y;
  ret = f(y);
  for (auto & p : ret)
    { p.second *= q; }
  for (auto p : f(r)) {
    int key; lint value; std::tie(key, value) = p;
    auto it = ret.find(key);
    if (it == ret.end())
      { ret.emplace(key, value); }
    else
      { it->second += value; }
  }
  return ret;
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int q; std::cin >> n >> q;
  std::vector< lint > b(q);
  for (auto & x : b) std::cin >> x;
  std::reverse(all(b));
  constexpr lint linf = 1LL << 60;
  auto min = linf;
  for (auto x : b) {
     if (cmn(min, x))
       { a.emplace_back(x); }
  }
  std::reverse(all(a));
  if (n < a.front())
    { a.insert(a.begin(), n); }
  auto map = f(a.back());
  debug(map);
  std::vector< lint > ret(n, 0);
  for (auto p : map) {
    int key; lint value; std::tie(key, value) = p;
    ret.at(key - 1) += value;
  }
  debug(ret);
  std::reverse(all(ret));
  std::partial_sum(all(ret), ret.begin());
  std::reverse(all(ret));
  debug(ret);
  for (auto x : ret)
    { std::cout << x << std::endl; }
  return 0;
}