#include <string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef pair<long long,long long> P;
//typedef pair<long long,P> P1;
//typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define se second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define rrep(i,x) for(long long i=x-1;i>=0;i--)
#define rrepn(i,x) for(long long i=x;i>1;i--)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())


#define ALL(v)  (v).begin(),(v).end()
//#define MAX(a,b) if(a>b)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))


const string MINUSINF = "-";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
void chmax(string &a, string b) {
    if (a == MINUSINF) a = b;
    else if (a.size() < b.size()) a = b;
    else if (a.size() == b.size()) {
        if (a < b) a = b;
    }
}


template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define pr printf
#define re return
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)


int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

stack<long long> sta;   
queue<long long> que;
deque<long long> dque;

set <string> s_set;



//ll dp[13][100010]={};
//ll dp[100010][3];
string dp[11000];


//最大公約数
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }

//最大公約数 複数個
int gcd(const vector<int> &v) {
	int ret = v[0];
	for (int i = 1; i < v.size(); i++)
		ret = gcd(ret, v[i]);
	return ret;
}

//最小公倍数 複数個
int lcm(const vector<int> &v) {
	int ret = v[0];
	for (int i = 1; i < v.size(); i++)
		ret = lcm(ret, v[i]);
	return ret;
}

struct Student {
  string name;
  int no, point;
};


// a < b ならtrueを返す
bool comp(const Student& a, const Student& b) {
  if (a.name != b.name)
    return a.name < b.name; // 高い順に並べたいので演算子を逆に
  if (a.point != b.point)
    return a.point > b.point; // 同様に比較演算子を反転
  return a.no < b.no;
}


//	文字列置換
std::string replaceOtherStr(std::string &replacedStr, std::string from, std::string to) {
    const unsigned int pos = replacedStr.find(from);
    const int len = from.length();
 
    if (pos == std::string::npos || from.empty()) {
        return replacedStr;
    }
 
    return replacedStr.replace(pos, len, to);
}


//	素因数分解
void countPN(int n, std::vector<int> &count)//nを素因数に分解し、countを更新
{
	int m = n;
	for(int i=2 ; i*i<=n ; ++i)
	{
		while(m%i == 0)
		{
			m /= i;
			count[i]++;
		}
		if(m==1) break;
	}
	if(m!=1) count[m]++;

}

//	コンビネーション
const int MAX_N = 2000000;
ll inv[MAX_N + 10];
ll fac[MAX_N + 10], facInv[MAX_N + 10];
class MATH{
public:
    MATH(){
        inverse();
        factroial();
    }
    ll nCk(ll n, ll k){// n! / k!*(n-k)!
        if(k < 0 || k > n) return 0;
        ll ret = fac[n];
        (ret *= facInv[k]) %= mod;
        (ret *= facInv[n - k]) %= mod;
        return ret;
    }
    ll nHk(ll n, ll k){// nHk = n+k-1 C k = (n+k-1)! / k! * (n-1)!
        if(n == 0 && k == 0) return 1;
        ll ret = fac[n + k - 1];
        (ret *= facInv[k]) %= mod;
        (ret *= facInv[n - 1]) %= mod;
        return ret;
    }
    ll nPk(ll n, ll k){//nPk = n! / (n-k)!
        if(k < 0 || k > n) return 0;
        ll ret = fac[n];
        (ret *= facInv[n - k]) %= mod;
        return ret;
    }
private:
    void inverse(void){
        inv[1] = 1;
        for (int i = 2; i <= MAX_N; ++i){
            // inv[i] = mod - (mod / i) * inv[mod % i] % mod;
            inv[i] = inv[mod % i] * (mod - mod / i) % mod;
        }
    }
    void factroial(void){
        fac[0] = facInv[0] = 1;
        for (int i = 1; i <= MAX_N; ++i){
            fac[i] = (fac[i - 1] * i) % mod;
            facInv[i] = (facInv[i - 1] * inv[i]) % mod;
        }
    }
};

//	いもす法
std::vector<int> getCumSum(std::vector<int> baseImos){
    int baseSize = baseImos.size();
    std::vector<int> cumSum(baseSize, 0);
    
    cumSum[0] = baseImos[0];
    for(int i=1; i<baseSize; ++i){
        cumSum[i] = cumSum[i-1] + baseImos[i];
    }
    return cumSum;
}

typedef vector<int> vi;

//	DFS		(ABC026 A  高橋君の給料)
/*
int dfs(vector<vi> ch, int u){
	if(ch[u].empty()) return 1;
	int mi = INF, ma = 0;
	for(int v : ch[u]){
		int r = dfs(ch, v);
		mi = MIN(mi, r);
		ma = MAX(ma, r);
	}
	return mi + ma + 1;
}
*/

//	DFS		(ABC029 C  Brute-force Attack)
/*
void dfs(int n, string s) {
  if (n == 0) cout << s << endl;
  else {
    dfs(n-1, s + "a");
    dfs(n-1, s + "b");
    dfs(n-1, s + "c");
  }
}
*/

using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

vector<int> res;
Graph G;

//	DFS	& 二部グラフ	(ABC126 D  Even Relation 同色の2頂点の長さは偶数)

// v を c に塗る。p は v の親
void dfs(int v, int p, int c) {
    res[v] = c;
    for (auto e : G[v]) {
        if (e.first == p) continue;
        if (e.second & 1) dfs(e.first, v, 1-c);
        else dfs(e.first, v, c);
    }
}

//	DFS	(ABC138 D  Ki)
vector<int> g[200020];
int s[200020];
bool used[200020];

void dfs(int x){
	used[x]=1;
	for(auto y:g[x]){
		if(used[y]) continue;
		s[y]+=s[x];
		dfs(y);
	}
}


long long A,B,C,D,E,F,H,I,J,L,N,M,K,O,P,Q,R,S,T,U,V,W,X,Y,Z;
long long sum,sum1,sum2,sum3,sum4;
long long flg,flg1,flg2,flg3,cnt,cnt1,cnt2,cnt3,cnt4;
long long wk,wk1,wk2,wk3,wk4;
long long ans;

bool f;

long long weight[110], value[110]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に
ll a[100010][3]; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1], a[i][2] にしてしまう
long long n,h[100005];
vector<long long> p, c;
int vis[200001];

vector<string> fi;
int Left[2100][2100], Right[2100][2100], Up[2100][2100], Down[2100][2100];

long long match[10] = {2,5,5,4,5,6,3,7,6};




int main(){
	
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	long long max,max1;
	long long min,min1;

	sum=sum1=sum2=sum3=sum4=0;
	flg=flg1=flg2=flg3=cnt=cnt1=cnt2=cnt3=cnt4=0;
	max=max1=0;
	wk=wk1=wk2=wk3=wk4=0;
	ans=0;
	min=min1=INF;

	
	
	//**************************こどふぉ用(#575 Div.3 B) ******************************************
	/*
	cin >> T;
	while(T--){
		cin >> N >> K;
		v.clear();
		for(int i=1;i<=N;i++){
			cin >> a[i];
			if(a[i]%2==1) v.pb(i);
		}
		if(v.size()<K || v.size()-(K-1)%2==0) cout << "NO\n";
		else{
			cout << "YES\n";
			for(int i=0;i<K-1;i++){
				cout << v[i] << " ";
			}
			cout << N << "\n";
		}
	}
	*/
	
	//**************************ここからスタート******************************************
	//std::cin >> N;
	//std::cin >> N >> M;
	//std::cin >> N >> M >> K;
	//std::cin >> N >> K;
	//std::cin >> A >> B;
	//std::cin >> A >> B >> C;
    
	//std::vector<long long> v(N);
	//std::vector<long long> w(N);
	//std::vector<long long> x(N);
	//std::vector<int> v(100, 0);
	//int a[26]={0};
	//vector<long long> flagment(N, 0);
	
	//vec.push_back(i);
	//accumulate(vec.begin(), vec.end(), 0)
    //v.resize
    
	// 配列入力1
	//通常
	
	int n, m; cin>>n>>m;
	ll b;
	priority_queue<ll> que;
	
	for(int i=0; i<n; i++){
		cin>>b;
		que.push(b);
	}
	
	int ans=0;
	for(int i=1; i<=m; i++){
		/*
		for(int b:vb[i]) que.push(b);
		if(!que.empty()){
			ans+=que.top();
			que.pop();
		}
		*/
		wk=que.top();
		que.pop();
		wk/=2;
		que.push(wk);
	}
	for(int i=0; i<n; i++){
		wk=que.top();
		sum+=wk;
		que.pop();
	}
	
	cout<<sum<<endl;
    return 0;
	
	
	/*
	if(1){
    	printf("%lld",N);
    	//printf("%lld",N);
    	//puts("Yes");
    	//printf("%d",st.size());
    	//文字列の出力
    	//std::cout << s << std::endl;
    	//printf("%.12f\n",ret);
    	//cout << sum << endl;
	}
	else{
		//puts("No");
	}
	return 0;
	*/

	//文字列入力
	/*
	string s,t;
	std::cin >> s;
	//sort(s.begin(), s.end());
	for(long long i=0; i<s.length(); i++){
		
		//wk=(s[i+2]-'0')+10*(s[i+1]-'0')+100*(s[i]-'0');
		if(s[i]!='1'){
		}	
	}
	*/
	
	
	//●●●	文字列の置換
	/*
	string s,t;
	std::cin >> s;
    
	while(t!=s){
		t=s;
		replaceOtherStr(s, "a", "b");
	}
	*/
	
	//●●●	現れない文字の一番最初の文字	(ABC071 B Not Found)
	/*
	string s;
	cin>>s;
	int a[26]={0};
	for(int i=0;i<s.length();i++){
		a[s[i]-'a']=1;
	}
	for(int i=0;i<26;i++){
		if(!a[i]){
			printf("%c",'a'+i);
			return 0;
		}
	}
	*/
	
	//●●●	to_string	(ABC136  B Uneven Numbers偶数桁の数字は除去)
	/*
	string s;
	cin >> N;
	repn(i,N){
		s=to_string(i);
		if(s.size()%2==1){
			cnt++;
		}
	}
	*/
	//●●●	別解 stringlenを使用する場合
  	/*
	char s[10];
	repn(i,N){
		sprintf(s,"%lld",i);
		if(strlen(s)%2==1)ans++;
	}
	pr("%lld\n",ans);
	re 0;
	*/

	
	//●●●	複数の文字列に共通して含む文字からできる最長の文字列を出力（複数ある時は辞書順で最小）	(ABC058  C 怪文書 )
	
	/*
	int d[26];
	rep(i,26)d[i]=10000000;
	CASET{								//	これを使用時は cin >> N不要
		string s;
		int a[26]={};
		cin>>s;
		rep(i,s.length())a[s[i]-'a']++;
		rep(i,26)d[i]=MIN(d[i],a[i]);
	}
	rep(i,26){
		rep(j,d[i])putchar('a'+i);
	}
	return 0;
	*/
	
	//●●●	複数の文字列に含む文字	その２	(こどふぉ Educational Div2 A)
	/*
	string s,t;
	std::vector<long long> v(N);
	for(long long i=0; i<N; i++){
		
		std::cin >> s;
		std::cin >> t;
 
		for(long long i=t.length()-1; i>0; i--){
			if(t[i]!='1'){
				cnt1++;
			}
			else{
				break;
			}
		}
 
		for(long long i=s.length()-1; i>0; i--){
			if(s[i]!='1'){
				cnt++;
			}
			else{
				if(cnt>=cnt1){
					break;
				}
				else{
					cnt++;
				}
			}
		}
		
		v[i]=cnt-cnt1;
		cnt=0;
		cnt1=0;
	}
	
	for(long long i=0; i<N; i++){
		printf("%lld\n",v[i]);
	}
	return 0;	
	*/
	
		
	//●●●	部分文字列を何個含むか(白昼夢	ABC049 C)
	/*
	string s;
	cin >> s;
	dp[0] = 1;
	for (int i = 0; i < s.size(); i++) {
		if (dp[i] == 0)continue;
		if (i + 5 <= s.size() && s.substr(i, 5) == "dream")dp[i + 5] = 1;
		if (i + 7 <= s.size() && s.substr(i, 7) == "dreamer")dp[i + 7] = 1;
		if (i + 5 <= s.size() && s.substr(i, 5) == "erase")dp[i + 5] = 1;
		if (i + 6 <= s.size() && s.substr(i, 6) == "eraser")dp[i + 6] = 1;
	}
	if (dp[s.size()] == 1)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
	*/
	
	
	//●●●	部分文字列を含むか否か&複数の文字列の処理（東工大2019）
	/*
	int N;
	cin >> N;
	vector<string> ans;
	for(int i=0;i<N;i++){
		string s;
		cin >> s;
		//*okyo*ech*
		if(regex_match(s, std::regex(".*okyo.*ech.*")))ans.push_back("Yes");
		else ans.push_back("No");
	}
	for(auto x:ans)cout << x << endl;	
	*/
	
	
	//●●●	文字列Si != Si+1の最大値(Dividing a String	AGC037 A)
	/*
	string s;
	cin >> s;
	int ans = 0;
	int n = s.size();
	string bef = "", now = "";
	rep(i,n){
		now += s[i];
		if (bef!=now){
			bef = now;
			now = "";
			ans++;
		}
		}
	cout << ans << endl;
	re 0;
	*/
	
	//●●●  ペア関連
	/*
	vector<pair<long long, long long> > p(M);
	for(long long i=0; i<M; i++){
		long long a, b;
		cin >> a >> b;
		p[i] = make_pair(a, b);
	}
    
	sort(p.begin(), p.end());
	sort(p.begin(), p.end(),greater<pair<long long,long long> >());
	
	//●●●	通常（ペア用）
	
	for(long long i=0; i<N; i++){
		p[0].fi=0;
		p[0].se=0;
	}
	*/	

	//●●●  set関連  (ABC 73 C rite and Erase   set典型)
	/*
	std::set<long long> st;
	for(long long i=0; i<N; i++){
		std::cin >> v[i];
		if(st.find(v[i])==st.end()){
			st.insert(v[i]);
		}
		else{
			st.erase(v[i]);
		}
	}
	*/
	//●●● set 文字列関連
	/*
	string s;
	for(long long i=0; i<S.size(); i++) {
    	s.insert(S[i]);
  	}
  	cnt=(int)s.find('a');
  	*/	
  	
  	
	//●●● set && pair  (ABC68 C Cat Snuke and a Voyage 2つの定期便で到着できるか)  	
	/*
	set<pair<int, int> > s;
	for (int i = 0; i < M; i++) {
		cin >> a >> b;
		s.insert(make_pair(a, b));
	}
	bool ret = false;
	for (int i = 2; i <= N - 1; i++) {
		if (s.count(make_pair(1, i)) && s.count(make_pair(i, N))) {
			ret = true;
		}
	}
	*/

	//●●●	map 文字列 (ABC137 Green Bin アナグラム文字列の組み合わせ)
	/*
	std::map<std::string, int> freq;
	ans = 0;
	while(N--) {
		std::string str;
		std::cin >> str;
		std::sort(str.begin(), str.end());
		ans += freq[str]++;
	}
	
	pr("%lld\n",ans);
	re 0;
	ans=0;
	*/
	
	//●●●	別解 文字列のvector
	/*
	vector<string> ABC;
	rep(i, N) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		ABC.push_back(s);
	}
	sort(ABC.begin(), ABC.end());
	long long now = 1;
	for (int i = 1; i < ABC.size(); ++i) {
		if (ABC[i] != ABC[i - 1]) {
			ans += now * (now - 1LL) / 2LL;
			now = 1;
		}
		else {
			now++;
		}
	}
	ans += now * (now - 1LL) / 2LL;
	cout << ans << endl;
	re 0;
	*/
	
	//●●●	map 関連 (ABC82 Good Sequence 配列の要素と要素の数が等しい)
	/*
	map<long long,long long> nums;
	// 配列入力1
	for(long long i=1; i<=N; i++){
		std::cin >> wk;
		nums[wk]++;
	}
	for (map<long long, long long>::iterator it = nums.begin(); it != nums.end(); ++it) {
		if(it->second!=0){
			if(it->second>=it->first){
				sum+=it->second - it->first;
			}
			else{
				sum+=it->second;
			}
		}
	}
	*/
	
	//●●●	map 文字列関連 (ABC110 C String Transformation 文字を交換して同じ文字にできるか)
	/*
	bool ok = true;
	map<char,char> ma, ima;
	for (int i = 0; i < S.size(); ++i) {
		char s = S[i], t = T[i];
		if (ma.count(s)) if (ma[s] != t) ok = false;
		if (ima.count(t)) if (ima[t] != s) ok = false;
		ma[s] = t; ima[t] = s;
	}	
	*/
	
	//●●●	スタック・ポップ関連
	/*
	for(long long i=0; i<N; i++){
		std::cin >> wk;
		sta.push(wk);
		que.push(wk);	
	}
	for(long long i=0; i<N; i++){
		printf("%lld ",sta.top() );
		printf("%lld ",que.front() );
		sta.pop();
		que.pop();
	}
	*/
	
	//●●●	デキュー関連 (ABC66 C pushpush  先頭と後方の交互に詰める)
	/*
	f=0;
	for(int i=1;i<=N;i++){
		std::cin >> wk;
		if(!f)dque.push_back(wk);
		else dque.push_front(wk);
		f^=1;
	}
	if(N&1)while(!dque.empty())printf("%d ",dque.back()),dque.pop_back();
	else while(!dque.empty())printf("%d ",dque.front()),dque.pop_front();
	puts("");
	return 0;
	*/
	
	
	//●●●	dp関連	(ABC129 C Typical Stairs)
	/*
	ll dp[1000005];

	dp[0]=1;
	long long j;
	j=1;
    for(long long i=1; i<=N; i++){
		if(i==v[j]){
			dp[i]=0;
			j++;
		}
		else{
			dp[i]=(dp[i-1]+dp[i-2])%mod;
		}
	}
	printf("%lld",dp[N]);
	return 0;
	*/
	
	//●●●	dp関連	(dp Educational A	Flog1)
	/*
	cin >> N;
	for (int i = 0; i < N; ++i) cin >> h[i];

	// 初期化 (最小化問題なので INF に初期化)
	for (int i = 0; i < 100010; ++i) dp[i] = INF;

	// 初期条件
	dp[0] = 0;

	// ループ
	for (int i = 1; i < N; ++i) {
		chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}

    // 答え
    cout << dp[N-1] << endl;
	*/
	
	
	//●●●	dp関連	(dp Educational		C Vacation)	
	/*
	cin >> N;
	for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];

	// 初期化は既に 0 に初期化される
	// 初期条件も既に 0 で OK

	// ループ
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 3; ++j) {
			for (int k = 0; k < 3; ++k) {
				if (j == k) continue;
				chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
			}
		}
	}
	// 答え
	long long res = 0;
	for (int j = 0; j < 3; ++j) chmax(res, dp[N][j]);
	cout << res << endl;
	*/
	
	//●●●	dp関連	(dp Educational		D Knapsack 1)
	/*
	ll dp[110][100100] = {0};
	 cin >> N >> W;
	for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

	// DPループ
	for (int i = 0; i < N; ++i) {
		for (int sum_w = 0; sum_w <= W; ++sum_w) {

			// i 番目の品物を選ぶ場合
			if (sum_w - weight[i] >= 0) {
				chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
			}

			// i 番目の品物を選ばない場合
			chmax(dp[i+1][sum_w], dp[i][sum_w]);
		}
	}
	// 最適値の出力
	cout << dp[N][W] << endl;
	*/
	
	//●●●	dp関連 一部の桁が？	(abc135 D	Digits Parade)	
	/*
	string s; cin>>s;
	int n=s.size();
	reverse(s.begin(), s.end());
	dp[0][0]=1;
	int p=1;
	for(int i=0; i<n; i++){
		if(s[i]!='?'){
			int x=(s[i]-'0')*p%13;
			for(int j=0; j<13; j++){
				(dp[(j+x)%13][i+1]+=dp[j][i])%=mod;
			}
		}else{
			for(int k=0; k<10; k++){
				int x=k*p%13;
				for(int j=0; j<13; j++){
					(dp[(j+x)%13][i+1]+=dp[j][i])%=mod;
				}
			}
		}
		p=p*10%13;
	}
	cout<<dp[5][n]<<endl;
	return 0;
	*/
	
	//●●●	dp関連 	マッチで最大値を作る & stringの比較方法(ABC118 D  Match Matching)
	/*
	int N, M; cin >> N >> M;
	vector<int> A(M);
	for (int i = 0; i < M; ++i) cin >> A[i];

	// 初期化
	for (int i = 0; i < 11000; ++i) dp[i] = MINUSINF;

	// 初期条件
	dp[0] = "";

	// DP ループ
	for (int i = 0; i <= N; ++i) {
		if (dp[i] == MINUSINF) continue;
		for (auto a : A)  chmax(dp[i+match[a-1]], dp[i] + (char)('0' + a));
	}
	cout << dp[N] << endl;
	re 0;
	*/
	
	//●●●	全bit探索	(ABC104 C  All Green コンプリートボーナス)
	/*
	cin >> D >> G;
	p.resize(D); c.resize(D);
	for (int i = 0; i < D; ++i) cin >> p[i] >> c[i];

	long long res = 1<<29;
	for (int bit = 0; bit < (1<<D); ++bit) {
		long long sum = 0;
		long long num = 0;
		for (int i = 0; i < D; ++i) {
			if (bit & (1<<i)) sum += c[i] + p[i] * 100 * (i+1), num += p[i];
		}
		if (sum >= G) res = MIN(res, num);
		else {
			for (int i = D-1; i >= 0; --i) {
				if (bit & (1<<i)) continue;
				for (int j = 0; j < p[i]; ++j) {
					if (sum >= G) break;
						sum += 100 * (i+1);
							++num;
				}
			}
			res = MIN(res, num);
		}
	}
	cout << res << endl;
	*/
	
	//●●●	2bit	(こどふぉ#581 div2 A BowWow and the Timetable)
	/*
	string s;
	cin >> s;
	for(int i=0; i<(int)s.size(); i++) sum += s[i] - '0';
	if(sum == 0) printf("0");
	else if(sum == 1) printf("%d", s.size()/2);
	else printf("%d", (s.size()+1)/2);
	return 0;
	*/
	
	
	
	//●●●	BFS	(ABC001 B  リモコン 7*2)
	/*
	const int op[] = {-1, -5, -10, 1, 5, 10};
	cin >> A >> B;
	queue<int> que;
	que.push(A);
	vector<int> dp(41, INF);
	dp[A] = 0;
	while (!que.empty()) {
		const int tmp = que.front();
		que.pop();
		for (int i = 0; i < 6; ++i) {
			int next = tmp + op[i];
			if (next < 0 || 40 < next || dp[next] < dp[tmp]+1)continue;//過去に行ったことがあるものを除去
			dp[next] = dp[tmp] + 1;
			que.push(next);
		}
	}
	cout << dp[B] << endl;
	*/
	
	//●●●	DFS	(ABC026 C  高橋君の給料)
	/*
	int n;
	cin >> n;
	vector<vi> ch(n);				//typedef vector<int> vi;
	rep(i, n-1){
		int p; cin >> p;
		ch[p-1].pb(i + 1);
	}
	cout << dfs(ch, 0) << endl;
	return 0;
	*/

	//●●●	DFS	(ABC029 C  Brute-force Attack)
	/*
	int n;
	cin >> n;
	dfs(n, "");
	return 0;	
	*/
	
	
	//●●●	DFS	(ABC138 D  Ki)
	/*
	int q;
	cin>>n>>q;
	for(int i=0; i<n-1; i++){
		int a, b; cin>>a>>b; a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for(int i=0; i<q; i++){
		int p, x; cin>>p>>x;
		p--;
		s[p]+=x;
	}
	dfs(0);
	for(int i=0; i<n; i++){
		cout<<s[i]<<" ";
	}
	cout<<endl;
	return 0;
	*/
	
	
	//●●●	DFS	(ABC129 D  Lamp)	
	/*
	// 入力
	cin >> H >> W;
	fi.resize(H);
	for (int i = 0; i < H; ++i) cin >> fi[i];

	// 前処理
	for (int i = 0; i < H; ++i) {
		int cur = 0;
		for (int j = 0; j < W; ++j) {
			if (fi[i][j] == '#') cur = 0;
			else ++cur;
			Left[i][j] = cur;
		}
	}
	for (int i = 0; i < H; ++i) {
		int cur = 0;
		for (int j = W-1; j >= 0; --j) {
			if (fi[i][j] == '#') cur = 0;
			else ++cur;
			Right[i][j] = cur;
		}
	}
	for (int j = 0; j < W; ++j) {
		int cur = 0;
		for (int i = 0; i < H; ++i) {
			if (fi[i][j] == '#') cur = 0;
			else ++cur;
			Up[i][j] = cur;
		}
	}
	for (int j = 0; j < W; ++j) {
		int cur = 0;
		for (int i = H-1; i >= 0; --i) {
			if (fi[i][j] == '#') cur = 0;
			else ++cur;
			Down[i][j] = cur;
		}
	}
	

	// 集計
	int res = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (fi[i][j] == '#') continue;
			res = MAX(res, Left[i][j] + Right[i][j] + Up[i][j] + Down[i][j] - 3);
		}
	}
	cout << res << endl;
	re 0;
	*/
	
	//●●●	二部グラフ	(ABC126 D  Even Relation 同色の2頂点の長さは偶数)	
	
	cin >> N;
	G.assign(N, vector<Edge>());
	for (int i = 0; i < N-1; ++i) {
		int u, v, w; cin >> u >> v >> w;
		--u, --v;
		G[u].push_back(Edge(v, w));
		G[v].push_back(Edge(u, w));
	}
	res.assign(N, 0);
	dfs(0, -1, 1);
	for (auto v : res) cout << v << endl;
	re 0;
	
	
	//●●●	最小公倍数関連	(ABC70 C Multiple Clocks)
	/*
	std::vector<int> v(N);
	rep(i, N) {
		cin >> v[i];
	}	
	cout << lcm(v) << endl;
	return 0;
	*/
	
	
	//●●●	最大公約数関連	(ABC70 C Multiple Clocks)
	/*
	std::vector<int> v(N);
	rep(i, N) {
		cin >> v[i];
	}	
	cout << gcd(v) << endl;
	return 0;
	*/

	//●●●	倍数 （こどふぉ#584  Paint the Numbers)
	/*
	std::cin >> N;
	
	std::vector<long long> v(N);
	
	for(long long i=0; i<N; i++){
		std::cin >> v[i];
	}
	
	vector<bool> used(N, false);
	while (true) {
		ll mi = INF;
		rep(i, N) {
			if (used[i]) continue;
			mi=MIN(mi, v[i]);
		}
		if (mi >= INF) break;
		++ans;
		rep(i, N) {
			if (used[i]) continue;
			if (v[i] % mi == 0) {
				used[i] = true;
			}
		}
	}
	pr("%lld",ans);
	re 0;
	*/

	
	//●●●	GCD	(ABC118 C Monsters Battle Royale)
	/*
	vector<ll> a(N);
	for(ll i=0;i<N;i++) cin>>a[i];
	ans=a[0];
	for(ll i=0;i<N;i++) ans=gcd(ans,a[i]);
	cout<<ans<<endl;
	*/
	    
	
	//●●● 素因数分解関連	(ABC 063 C Factors of Factorial N!の約数の個数を10^9+7で割った余り)
	/*
	std::vector<int> count(1024);
	for(auto &x : count) x = 0;
	for(int n=2; n<=N; n++) countPN(n, count);

	ans = 1;
	for(int n=2; n<=N; n++)
	{
		if(count[n] != 0)
		{
			ans *= count[n]+1;
			ans %= mod;
		}
	}
	std::cout << ans << std::endl;
	return 0;
	*/
	
	
	//●●● コンビネーション	(ABC 034 C 経路)
	/*
	int w, h; cin >> w >> h;
    // (w + h  - 2)! / ((w-1)! * (h-1)!)
    MATH ma;
    cout << ma.nCk(w + h - 2, w - 1) << endl;
    return 0;
    */

	//●●●	どこまでか分からないけど調べたい (ABC072 C Together +1or0or-1である要素の数を最大化する)
	/*
	int n, a, c[100009];
	for (int i = 0; i < n; i++) cin >> a, c[a]++;
	int ret = 0;
	for (int i = 0; i <= 100000; i++) ret = MAX(ret, c[i] + c[i + 1] + c[i + 2]);
	cout << ret << endl;
	return 0;
	*/	
	
	
	
	//●●●	modの使い方(ABC 050 C Lining Up 左右の人数が既知)
	//(ans *= 2) %= mod;
	
    
	//●●●	lowerbound , upper bound	(ABC77 C Snuke Festival)
	/*
	vector<int> a, b, c;
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	for (int i: b) {
		int x = lower_bound(a.begin(), a.end(), i) - a.begin();
		int y = upper_bound(c.begin(), c.end(), i) - c.begin();
		y = c.size() - y;
		ans += ll(x) * y;
	}
	*/
	
	//●●●	配列を繋げた時の転倒数（modの使い方を含む）(most strong stududent B)
	/*
	int n; ll k;
	cin>>n>>k;
	int a[2020];
	for(int i=0; i<n; i++) cin>>a[i];
	ll ans=0;
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			if(a[i]>=a[j]) continue;
			if(i>j){
				ll s=k*(k+1)/2%mod;
				ans+=s;
				ans%=mod;
			}else{
				ll s=k*(k-1)/2%mod;
				ans+=s;
				ans%=mod;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
	*/

	//●●●	累積和	(ABC037 C 総和)
	/*
	for(long long i=0; i<N; i++){
		std::cin >> v[i];
	}
	for(long long i=0; i<N; i++){
		if(i!=0){
			w[i]=w[i-1]+v[i];
		}
		else{
			w[i]=v[0];
		}
	}
	for(long long i=K; i<=N; i++){
		if(i==K){
			sum+=w[K-1];
		}
		else{
			sum+= w[i-1]-w[i-K-1];
		}
	}
	pr("%lld",sum);
	*/
	
	//●●●	いもす法	(ABC035 C オセロ)
	/*

	int w = 10;
	int n, blockPos, len;
	std::cin >> n;
	std::vector<int> base(w+1, 0);
	for(int i=0; i<n; ++i){
		std::cin >> blockPos >> len;
		++base[blockPos];
		--base[blockPos+len];
	}
	
	std::vector<int> depth(getCumSum(base));
	for(int i=0; i<w; ++i){
		std::cout << depth[i] << " ";
	}
	std::cout << "\n";
	return 0;
	*/
	
	//●●●	3つのソート関連	（ABC128 B Guidebook）
	
	/*
	vector<Student> vec(n+1);
	for (long long i = 1; i <= n; i++){
		vec[i].no= i;
		cin >> vec[i].name >> vec[i].point;
	}
	sort(vec.begin(), vec.end(), comp);

	for (int i = 1; i < vec.size(); i++) {
		printf("%d\n",vec[i].no);
	}
	*/
	
	//●●●	pow, sqrt,整数判定関連
	/*
	wk+=pow(v[j][i]-v[m][i],2);	//	wkはdouble
	wk=sqrt(wk);				//	wkはdouble
	if(ceil(wk) == floor(wk)){	//	整数判定
	}
	*/
	
	//●●●	ある要素から前後の何個かを全探索（こどふぉ(#576 Div.2 B))
	/*
	for(int i=0; i<n; ++i){
		bool flg = true;
		for(int j=i-x; j<i; ++j) if(j>0 && a[j] < a[i]) flg = false;
		for(int j=i+1; j<=i+y; ++j) if(j<n && a[j] < a[i]) flg = false;
 
		if(flg){
			cout << i+1 << endl;
			return 0;
		}
	}	
	*/
	
	//●●●	各桁の取り出し (ABC42 C こだわり者いろはちゃん)
	/*
	long long a[10];
	string s;
	for(long long i=N; i<100000; i++){
		wk=i;
		s=to_string(i);
		while(cnt<s.size()){	
			a[cnt] = (wk % 10); 
			wk /= 10;// 1桁目を取り出す
			cnt++;
		}
		for(long long j=0; j<K; j++){
			for(long long k=0; k<cnt; k++){
				if(v[j]==a[k]){
					flg=1;
				}
			}
		}
		if(flg==0){
			pr("%lld",i);
			re 0;
		}
		flg=0;
		cnt=0;
	}
	pr("%lld",N);
	*/
	
	//	追加予定（確率、テストの最大点（こどふぉ）、仲直り、mapのこどふぉ）
	
	if(1){
    	printf("%lld",N);
    	//printf("%lld",N);
    	//puts("Yes");
    	//printf("%d",st.size());
    	//文字列の出力
    	//std::cout << s << std::endl;
    	//printf("%.12f\n",ret);
    	//cout << sum << endl;
	}
	else{
		//puts("No");
	}
	
	return 0;
}


Measured memory_bytes: 13816