#include "bits/stdc++.h"
using namespace std; 
#define all(c) c.begin(),c.end()
#define sz(x) int(x.size())
#define ar array
typedef long long ll ; 
typedef vector<int> vi;
#define mod 1000000007 
ll exp(ll x,ll y){
  x%=mod;
  ll res=1;
  while(y){
    if(y&1)
    res=res*x%mod;
    x=x*x%mod;
    y>>=1;
  }
  return res;
}
ll fact(ll n){
  ll res=1;
  for(ll i=2;i<=n;++i)
  (res*=i)%=mod;
  return res;
}
bool isprime(ll n){
  for(ll i=2;i*i<=n;++i)
  if(n%i==0) return 0;
  return 1;
}
map<ll,ll>mp1,mp2;
ll f1(ll x,ll y){
  if(y<=x) {
    return abs(x-y);
  }
  if(mp1.count(y)) return mp1[y];
  ll ans1=0,ans2=0;
  if(y%2) {
    ans1+=2+f1(x,(y-1)/2);
    ans2+=2+f1(x,(y+1)/2);
    return mp1[y]=min(ans1,ans2);
  }
  else return mp1[y]=1+f1(x,y/2);
}
ll f2(ll x,ll y){
  if(y<=2*x) {
    return abs(x-y);
  }
  if(mp2.count(y)) return mp2[y];
  ll ans1=0,ans2=0;
  if(y%2) {
    ans1+=2+f2(x,(y-1)/2);
    ans2+=2+f2(x,(y+1)/2);
    return mp2[y]=min(ans1,ans2);
  }
  else return mp2[y]=1+f2(x,y/2);
}
int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
ll x,y;
cin>>x>>y;
cout<<min(f1(x,y),f2(x,y));



   return 0;
}

#include <bits/stdc++.h>

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> A(N); rep(i, N) cin >> A[i];
    vector<ll> B(N, 0); rep(i, N-1) B[i+1] = B[i] + A[i+1]*(i+1); 
    ll mx = -1, sum = 0;
    for(ll k = 1; k <= N; k++){
        mx = max(mx, A[k-1]);
        sum += A[k-1];
        cout << k*(mx + sum) - B[k-1] << endl;
    }
    return 0;
}