#ifndef __clang__
#pragma GCC optimize "-O3"
#pragma GCC target "tune=native"
#endif
#ifdef ONLINE_JUDGE
#define NDEBUG 1
#endif
#include <stdio.h>
#include <bits/stdc++.h>

#define DESTRUCT2(p, a, b)                      \
  auto a = get<0>(p);                           \
  auto b = get<1>(p);

#define DESTRUCT3(p, a, b, c)                   \
  auto a = get<0>(p);                           \
  auto b = get<1>(p);                           \
  auto c = get<2>(p);

#define DESTRUCT4(p, a, b, c, d)                \
  auto a = get<0>(p);                           \
  auto b = get<1>(p);                           \
  auto c = get<2>(p);                           \
  auto d = get<3>(p);

#define FOR(i, n)     for(lli i = 0; i < (lli)(n); ++i)
#define FORU(i, j, k) for(lli i = (j); i <= (lli)(k); ++i)
#define FORD(i, j, k) for(lli i = (j); i >= (lli)(k); --i)

#define SQ(x) ((x)*(x))

#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back

using namespace std;

template<typename... As>
struct tpl : public std::tuple<As...> {
  using std::tuple<As...>::tuple;

  template<typename T = tuple<As...> >
  typename tuple_element<0, T>::type const&
  x() const { return get<0>(*this); }
  template<typename T = tuple<As...> >
  typename tuple_element<0, T>::type&
  x() { return get<0>(*this); }

  template<typename T = tuple<As...> >
  typename tuple_element<1, T>::type const&
  y() const { return get<1>(*this); }
  template<typename T = tuple<As...> >
  typename tuple_element<1, T>::type&
  y() { return get<1>(*this); }

  template<typename T = tuple<As...> >
  typename tuple_element<2, T>::type const&
  z() const { return get<2>(*this); }
  template<typename T = tuple<As...> >
  typename tuple_element<2, T>::type&
  z() { return get<2>(*this); }

  template<typename T = tuple<As...> >
  typename tuple_element<3, T>::type const&
  w() const { return get<3>(*this); }
  template<typename T = tuple<As...> >
  typename tuple_element<3, T>::type&
  w() { return get<3>(*this); }
};

using lli   = long long int;
using llu   = long long unsigned;

using pii   = tpl<lli, lli>;
using piii  = tpl<lli, lli, lli>;
using piiii = tpl<lli, lli, lli, lli>;
using vi    = vector<lli>;
using vii   = vector<pii>;
using viii  = vector<piii>;
using vvi   = vector<vi>;
using vvii  = vector<vii>;
using vviii = vector<viii>;

template<class T>
using min_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>
using max_queue = priority_queue<T>;

template<size_t... I>
struct my_index_sequence {
  using type = my_index_sequence;
  static constexpr array<size_t, sizeof...(I)> value = { {I...} };
};

namespace my_index_sequence_detail {
  template<typename I, typename J> struct concat;
  template<size_t... I, size_t... J>
  struct concat<my_index_sequence<I...>, my_index_sequence<J...> > :
    my_index_sequence<I..., (sizeof...(I)+J)...> { };
  template<size_t N> struct make_index_sequence :
    concat<typename make_index_sequence<N/2>::type, typename make_index_sequence<N-N/2>::type>::type { };
  template <> struct make_index_sequence<0> : my_index_sequence<>{};
  template <> struct make_index_sequence<1> : my_index_sequence<0>{};
}

template<class... A>
using my_index_sequence_for = typename my_index_sequence_detail::make_index_sequence<sizeof...(A)>::type;

template<class T, size_t... I>
void print_tuple(ostream& s, T const& a, my_index_sequence<I...>){
  using swallow = int[];
  (void)swallow{0, (void(s << (I == 0? "" : ", ") << get<I>(a)), 0)...};
}

template<class T>
ostream& print_collection(ostream& s, T const& a);
template<class... A>
ostream& operator<<(ostream& s, tpl<A...> const& a);
template<class... A>
ostream& operator<<(ostream& s, tuple<A...> const& a);
template<class A, class B>
ostream& operator<<(ostream& s, pair<A, B> const& a);

template<class T, size_t I>
ostream& operator<<(ostream& s, array<T, I> const& a) { return print_collection(s, a); }
template<class T>
ostream& operator<<(ostream& s, vector<T> const& a) { return print_collection(s, a); }
template<class T, class U>
ostream& operator<<(ostream& s, multimap<T, U> const& a) { return print_collection(s, a); }
template<class T>
ostream& operator<<(ostream& s, multiset<T> const& a) { return print_collection(s, a); }
template<class T, class U>
ostream& operator<<(ostream& s, map<T, U> const& a) { return print_collection(s, a); }
template<class T>
ostream& operator<<(ostream& s, set<T> const& a) { return print_collection(s, a); }

template<class T>
ostream& print_collection(ostream& s, T const& a){
  s << '[';
  for(auto it = begin(a); it != end(a); ++it){
    s << *it;
    if(it != prev(end(a))) s << " ";
  }
  return s << ']';
}

template<class... A>
ostream& operator<<(ostream& s, tpl<A...> const& a){
  s << '(';
  print_tuple(s, a, my_index_sequence_for<A...>{});
  return s << ')';
}

template<class... A>
ostream& operator<<(ostream& s, tuple<A...> const& a){
  s << '(';
  print_tuple(s, a, my_index_sequence_for<A...>{});
  return s << ')';
}

template<class A, class B>
ostream& operator<<(ostream& s, pair<A, B> const& a){
  return s << "(" << get<0>(a) << ", " << get<1>(a) << ")";
}

namespace std {
  namespace {
    template <class T>
    inline void hash_combine(size_t& seed, T const& v) {
      seed ^= hash<T>()(v) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
    template <class Tuple, size_t Index = tuple_size<Tuple>::value - 1>
    struct HashValueImpl {
      static void apply(size_t& seed, Tuple const& tuple) {
        HashValueImpl<Tuple, Index-1>::apply(seed, tuple);
        hash_combine(seed, get<Index>(tuple));
      }
    };
    template <class Tuple>
    struct HashValueImpl<Tuple, 0> {
      static void apply(size_t& seed, Tuple const& tuple) {
        hash_combine(seed, get<0>(tuple));
      }
    };
  }
  template <typename ... TT>
  struct hash<tuple<TT...>> {
    size_t operator()(tuple<TT...> const& tt) const {
      size_t seed = 0;
      HashValueImpl<tuple<TT...> >::apply(seed, tt);
      return seed;
    }
  };
  template <typename ... TT>
  struct hash<tpl<TT...>> {
    size_t operator()(tpl<TT...> const& tt) const {
      size_t seed = 0;
      HashValueImpl<tuple<TT...> >::apply(seed, tt);
      return seed;
    }
  };
}

lli read_positive(){
  char c; lli x=0;
  do { c = getchar(); } while(c<'0' || c>'9');
  while(c>='0'&&c<='9') {
    x=10*x+(c-'0');
    c = getchar();
  }
  return x;
}

//------------------------------------------------------------------------------

// --- BEGIN SNIPPET TREAP ---

struct treap;
using treap_ptr = treap*;

struct treap {
  treap(lli x_, lli sz=1) : l(0), r(0), heap(rand()), x(x_), bsize(sz), size(sz), sum(sz*x){ }
  treap_ptr l, r;
  lli heap;

  lli x;

  int bsize;
  lli sum;
  lli size;

  static lli get_size(treap_ptr a){ return a?a->size:0; }
  static lli get_sum(treap_ptr a){ return a?a->sum:0; }

  static void update(treap_ptr a){
    if(a){
      a->sum = a->bsize*a->x;
      if(a->l) a->sum += a->l->sum;
      if(a->r) a->sum += a->r->sum;
      a->size = a->bsize;
      if(a->l) a->size += a->l->size;
      if(a->r) a->size += a->r->size;
    }
  }

  static void push(treap_ptr){ }

  static treap_ptr merge(treap_ptr a, treap_ptr b){
    if(a == 0) return b;
    if(b == 0) return a;
    push(a); push(b);
    if(a->heap < b->heap){
      a->r = merge(a->r, b);
      update(a);
      return a;
    }else{
      b->l = merge(a, b->l);
      update(b);
      return b;
    }
  }

  static tpl<treap_ptr, treap_ptr> split_key(treap_ptr a, lli x){
    if(a == 0) return mt(nullptr, nullptr);
    push(a);
    if(x <= a->x){
      auto p = split_key(a->l, x);
      a->l = p.y();
      update(a);
      return mt(p.x(), a);
    }else{
      auto p = split_key(a->r, x);
      a->r = p.x();
      update(a);
      return mt(a, p.y());
    }
  }

  static tpl<treap_ptr, treap_ptr> split_pos(treap_ptr a, lli i){
    if(a == 0) return mt(nullptr, nullptr);
    push(a);
    if(i <= get_size(a->l)){
      auto p = split_pos(a->l, i);
      a->l = p.y();
      update(a);
      return mt(p.x(), a);
    }else{
      auto p = split_pos(a->r, i - get_size(a->l) - 1);
      a->r = p.x();
      update(a);
      return mt(a, p.y());
    }
  }

  static treap_ptr insert_key(treap_ptr a, lli x){
    auto p = split_key(a, x);
    return merge(merge(p.x(), new treap(x)), p.y());
  }

  static treap_ptr insert_pos(treap_ptr a, lli i, lli x){
    auto p = split_pos(a, i);
    return merge(merge(p.x(), new treap(x)), p.y());
  }
};

// --- END SNIPPET TREAP ---


const int N=2e5;
lli A[N];
lli ANS[N];
bool E[N];
lli L[N];

int main(){
  ios::sync_with_stdio(0); cin.tie(0);
  int n; cin >> n;
  FOR(i,n) cin >> A[i];
  FOR(i,n) ANS[i]=0;
  lli S=0; FOR(i,n) S += A[i];
  lli ls=0;
  FOR(i,n) {
    if(A[i]>ls) {
      E[i]=1; L[i]=ls; ls=A[i];
    }
  }
  treap_ptr t=0;
  FORD(i,n-1,0) {
    t=treap::insert_key(t,A[i]);
    if(E[i]) {
      auto p = treap::split_key(t,L[i]+1);
      lli r = treap::get_size(p.y());
      lli r2 = treap::get_sum(p.y());
      t=treap::merge(p.x(),new treap(L[i], r));
      ANS[i]=r2-r*L[i];
      S-=ANS[i];
    }
  }
  ANS[0]+=S;
  FOR(i,n) cout << ANS[i] << '\n';
  cout << flush;
  return 0;
}


Measured memory_bytes: 16768