#include <bits/stdc++.h>
//#include <atcoder/all>

typedef long long ll;
using namespace std;
//using namespace atcoder;

#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define _reps(i, s, n) for(ll i = (ll)(s); i < (ll)n; i++)
#define REP(...) _overload(__VA_ARGS__, _reps, _rep,)(__VA_ARGS__)
#define all(v) (v).begin(),(v).end()
#define UNIQUE(v) (v).erase( unique( all(v) ), (v).end() );
#define MOD 1000000007

ll powll(ll x, ll n){
	ll r = 1;
	while( n > 0 ){
		if( n & 1 )	r = x * r;
		x = x * x;
		n >>= 1;
	}
	return r;
}

int main(){
	ll n;	cin >> n;

	REP(i, 1, 38) REP(j, 1, 26){
		if( powll(3, i) + powll(5, j) == n ){
			cout << i << " " << j << endl;
			return 0;
		}
	}

	cout << -1 << endl;

	return 0;
}

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<ctime>
#include<map>
#define ll long long
#define MAXN 200005
#define uns unsigned
#define INF 0x3f3f3f3f 
#define lowbit(x) ((x)&(-(x)))
using namespace std;
inline ll read(){
	ll x=0;bool f=1;char s=getchar();
	while((s<'0'||s>'9')&&s>0){if(s=='-')f^=1;s=getchar();}
	while(s>='0'&&s<='9')x=(x<<1)+(x<<3)+s-'0',s=getchar();
	return f?x:-x;
}
int n;
ll sum,mx,a[MAXN],ans;
int main()
{
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	for(int i=1;i<=n;i++){
		mx=max(mx,a[i]);
		sum+=a[i],ans+=sum;
		printf("%lld\n",ans+mx*i);
	}
	return 0;
}