#include<bits/stdc++.h>
using namespace std;

#define LET(x, a)  __typeof(a) x(a)
#define TR(v, it) for(LET(it, v.begin()); it != v.end(); it++)
#define si(x) scanf("%d",&x)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 10000000000000LL
#define MOD 1000000007
#define SET(x,y) memset(x,y,sizeof(x));
#define LL long long int
#define ULL unsigned LL
#define PII pair<int, int>

LL a[200005];
vector<LL> v[200004];
bool dfs(LL cnode, LL napp, LL par = -1) {
    LL ccnt = v[cnode].size();
    if (par != -1)
        ccnt --;
    if (ccnt == 0)
        return a[cnode] >= napp;
    if (napp % ccnt != 0)
        assert(false);
    bool ret = true;
    for (LL i = 0; i < (LL)v[cnode].size(); i++)
        if (v[cnode][i] != par)
            ret &= dfs(v[cnode][i], napp / ccnt, cnode);
    return ret;
}
LL g = 0;
int n;
bool dfsLCM(LL cnode, LL par = -1, LL cpro = 1) {
    LL ccnt = v[cnode].size();
    if (par != -1)
        ccnt --;
    if (ccnt == 0)
        return true;
    LL ppro = cpro;
    cpro *= ccnt;
    if (cpro > INF)
        return false;
    if (g == 0)
        g = cpro;
    else {
        g /= __gcd(cpro, g);
        if (g > INF / cpro) {
            if (n == 100000) {
                cout << cnode << "   " << ppro << " ---->  " << cpro << "  " << ccnt << endl;
                cout << g << " " << g * cpro << endl;
            }
            return false;
        }
        g *= cpro;
    }
    for (LL i = 0; i < (LL)v[cnode].size(); i++)
        if (v[cnode][i] != par) {
            if (!dfsLCM(v[cnode][i], cnode, cpro))
                return false;
        }

    return true;
}
int main() {
    LL i, x, y;
    cin >> n;
    LL s = 0;
    for (i = 1; i <= n; i++) {
        cin >> a[i];
        s += a[i];
    }
    for (i = 1; i < n; i++) {
        cin >> x >> y;
        v[x].PB(y);
        v[y].PB(x);
    }
    LL lb = 0, ub = s, mid, ans = s;
    if (!dfsLCM(1)) ub = -1;
    else ub /= g;
    if (n == 100000)
        cout << g << "  " << ub << endl;
    while (lb <= ub) {
        mid = (lb + ub) / 2;
        if (dfs(1, mid * g)) {
            ans = mid * g;
            lb = mid + 1;
        } else {
            ub = mid - 1;
        }
    }
    cout << s - ans << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define LET(x, a)  __typeof(a) x(a)
#define TR(v, it) for(LET(it, v.begin()); it != v.end(); it++)
#define si(x) scanf("%d",&x)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 10000000000000LL
#define MOD 1000000007
#define SET(x,y) memset(x,y,sizeof(x));
#define LL long long int
#define ULL unsigned LL
#define PII pair<int, int>

int a[200005];
vector<int> v[200004];
bool dfs(int cnode, LL napp, int par = -1) {
    int ccnt = v[cnode].size();
    if (par != -1)
        ccnt --;
    if (ccnt == 0)
        return a[cnode] >= napp;
    if (napp % ccnt != 0)
        assert(false);
    bool ret = true;
    for (int i = 0; i < (int)v[cnode].size(); i++)
        if (v[cnode][i] != par)
            ret &= dfs(v[cnode][i], napp / ccnt, cnode);
    return ret;
}
LL g = 0;
bool dfsLCM(int cnode, int par = -1, LL cpro = 1) {
    int ccnt = v[cnode].size();
    if (par != -1)
        ccnt --;
    if (ccnt == 0)
        return true;
    if (cpro * ccnt > INF) {
        return false;
    }
    cpro *= ccnt;
    if (g == 0)
        g = ccnt;
    else {
        g = (g / __gcd(cpro, g));
        if (g * cpro > INF)
            return false;
        g *= cpro;
    }
    for (int i = 0; i < (int)v[cnode].size(); i++)
        if (v[cnode][i] != par) {
            if (!dfsLCM(v[cnode][i], cnode, cpro))
                return false;
        }

    return true;
}
int main() {
    int i, n, x, y;
    cin >> n;
    LL s  = 0;
    for (i = 1; i <= n; i++) {
        cin >> a[i];
        s += a[i];
    }
    for (i = 1; i < n; i++) {
        cin >> x >> y;
        v[x].PB(y);
        v[y].PB(x);
    }
    LL lb = 0, ub = s, mid, ans = s;
    if (!dfsLCM(1)) ub = -1;
    else ub /= g;
    while (lb <= ub) {
        mid = (lb + ub) / 2;
        if (dfs(1, mid * g)) {
            ans = mid * g;
            lb = mid + 1;
        } else {
            ub = mid - 1;
        }
    }
    cout << s - ans << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define LET(x, a)  __typeof(a) x(a)
#define TR(v, it) for(LET(it, v.begin()); it != v.end(); it++)
#define si(x) scanf("%d",&x)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 10000000000000LL
#define MOD 1000000007
#define SET(x,y) memset(x,y,sizeof(x));
#define LL long long int
#define ULL unsigned LL
#define PII pair<int, int>

LL a[200005];
vector<LL> v[200004];
bool dfs(LL cnode, LL napp, LL par = -1) {
    LL ccnt = v[cnode].size();
    if (par != -1)
        ccnt --;
    if (ccnt == 0)
        return a[cnode] >= napp;
    if (napp % ccnt != 0)
        assert(false);
    bool ret = true;
    for (LL i = 0; i < (LL)v[cnode].size(); i++)
        if (v[cnode][i] != par)
            ret &= dfs(v[cnode][i], napp / ccnt, cnode);
    return ret;
}
LL g = 0;
bool dfsLCM(LL cnode, LL par = -1, LL cpro = 1) {
    LL ccnt = v[cnode].size();
    if (par != -1)
        ccnt --;
    if (ccnt == 0)
        return true;
    cpro *= ccnt;
    if (cpro > INF)
        return false;
    if (g == 0)
        g = cpro;
    else {
        g /= __gcd(cpro, g);
        if (g > INF / cpro)
            return false;
        g *= cpro;
    }
    for (LL i = 0; i < (LL)v[cnode].size(); i++)
        if (v[cnode][i] != par) {
            if (!dfsLCM(v[cnode][i], cnode, cpro))
                return false;
        }

    return true;
}
int main() {
    LL i, n, x, y;
    cin >> n;
    LL s = 0;
    for (i = 1; i <= n; i++) {
        cin >> a[i];
        s += a[i];
    }
    for (i = 1; i < n; i++) {
        cin >> x >> y;
        v[x].PB(y);
        v[y].PB(x);
    }
    LL lb = 0, ub = s, mid, ans = s;
    if (!dfsLCM(1)) ub = -1;
    else ub /= g;
    if (n == 100000)
        cout << g << "   " << ub << endl;
    while (lb <= ub) {
        mid = (lb + ub) / 2;
        if (dfs(1, mid * g)) {
            ans = mid * g;
            lb = mid + 1;
        } else {
            ub = mid - 1;
        }
    }
    cout << s - ans << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define LET(x, a)  __typeof(a) x(a)
#define TR(v, it) for(LET(it, v.begin()); it != v.end(); it++)
#define si(x) scanf("%d",&x)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 10000000000000LL
#define MOD 1000000007
#define SET(x,y) memset(x,y,sizeof(x));
#define LL long long int
#define ULL unsigned LL
#define PII pair<int, int>

int a[200005];
vector<int> v[200004];
bool dfs(int cnode, LL napp, int par = -1) {
    int ccnt = v[cnode].size();
    if (par != -1)
        ccnt --;
    if (ccnt == 0)
        return a[cnode] >= napp;
    if (napp % ccnt != 0)
        assert(false);
    bool ret = true;
    for (int i = 0; i < (int)v[cnode].size(); i++)
        if (v[cnode][i] != par)
            ret &= dfs(v[cnode][i], napp / ccnt, cnode);
    return ret;
}
LL g = 0;
bool dfsLCM(int cnode, int par = -1, LL cpro = 1) {
    int ccnt = v[cnode].size();
    if (par != -1)
        ccnt --;
    if (ccnt == 0)
        return true;
    if (cpro * ccnt > INF) {
        return false;
    }
    cpro *= ccnt;
    if (g == 0)
        g = ccnt;
    else {
        g /= __gcd(cpro, g);
        if (g  > INF / cpro)
            return false;
        g *= cpro;
    }
    for (int i = 0; i < (int)v[cnode].size(); i++)
        if (v[cnode][i] != par) {
            if (!dfsLCM(v[cnode][i], cnode, cpro))
                return false;
        }

    return true;
}
int main() {
    int i, n, x, y;
    cin >> n;
    LL s  = 0;
    for (i = 1; i <= n; i++) {
        cin >> a[i];
        s += a[i];
    }
    for (i = 1; i < n; i++) {
        cin >> x >> y;
        v[x].PB(y);
        v[y].PB(x);
    }
    LL lb = 0, ub = s, mid, ans = s;
    if (!dfsLCM(1)) ub = -1;
    else ub /= g;
    while (lb <= ub) {
        mid = (lb + ub) / 2;
        if (dfs(1, mid * g)) {
            ans = mid * g;
            lb = mid + 1;
        } else {
            ub = mid - 1;
        }
    }
    cout << s - ans << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define LET(x, a)  __typeof(a) x(a)
#define TR(v, it) for(LET(it, v.begin()); it != v.end(); it++)
#define si(x) scanf("%d",&x)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 10000000000000LL
#define MOD 1000000007
#define SET(x,y) memset(x,y,sizeof(x));
#define LL long long int
#define ULL unsigned LL
#define PII pair<int, int>

int a[200005];
vector<int> v[200004];
bool dfs(int cnode, LL napp, int par = -1) {
    int ccnt = v[cnode].size();
    if (par != -1)
        ccnt --;
    if (ccnt == 0)
        return a[cnode] >= napp;
    if (napp % ccnt != 0)
        assert(false);
    bool ret = true;
    for (int i = 0; i < (int)v[cnode].size(); i++)
        if (v[cnode][i] != par)
            ret &= dfs(v[cnode][i], napp / ccnt, cnode);
    return ret;
}
LL g = 0;
bool dfsLCM(int cnode, int par = -1, LL cpro = 1) {
    int ccnt = v[cnode].size();
    if (par != -1)
        ccnt --;
    if (ccnt == 0)
        return true;
    if (cpro * ccnt > INF) {
        return false;
    }
    cpro *= ccnt;
    if (g == 0)
        g = ccnt;
    else {
        g = (g / __gcd(cpro, g));
        if (g * cpro > INF)
            return false;
        g *= cpro;
    }
    for (int i = 0; i < (int)v[cnode].size(); i++)
        if (v[cnode][i] != par) {
            if (!dfsLCM(v[cnode][i], cnode, cpro))
                return false;
        }

    return true;
}
int main() {
    int i, n, x, y;
    cin >> n;
    LL s  = 0;
    for (i = 1; i <= n; i++) {
        cin >> a[i];
        s += a[i];
    }
    for (i = 1; i < n; i++) {
        cin >> x >> y;
        v[x].PB(y);
        v[y].PB(x);
    }
    LL lb = 0, ub = s, mid, ans = 0;
    if (!dfsLCM(1)) ub = -1;
    else ub /= g;
    while (lb <= ub) {
        mid = (lb + ub) / 2;
        if (dfs(1, mid * g)) {
            ans = mid * g;
            lb = mid + 1;
        } else {
            ub = mid - 1;
        }
    }
    cout << s - ans << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define LET(x, a)  __typeof(a) x(a)
#define TR(v, it) for(LET(it, v.begin()); it != v.end(); it++)
#define si(x) scanf("%d",&x)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 1000000000
#define MOD 1000000007
#define SET(x,y) memset(x,y,sizeof(x));
#define LL long long int
#define ULL unsigned LL
#define PII pair<int, int>

int a[200005];
vector<int> v[200004];
bool dfs(int cnode, int napp, int par = -1) {
    int ccnt = v[cnode].size();
    if (par != -1)
        ccnt --;
    if (ccnt == 0)
        return a[cnode] >= napp;
    if (napp % ccnt != 0)
        return false;
    bool ret = true;
    for (int i = 0; i < (int)v[cnode].size(); i++)
        if (v[cnode][i] != par)
            ret &= dfs(v[cnode][i], napp / ccnt, cnode);
    return ret;
}
LL g = 0;
bool dfsLCM(int cnode, int par = -1, LL cpro = 1) {
    int ccnt = v[cnode].size();
    if (par != -1)
        ccnt --;
    if (ccnt == 0)
        return true;
    if (cpro > 1e14 / ccnt) {
        return false;
    }
    if (g == 0)
        g = ccnt;
    else {
        g = (g / __gcd((LL)ccnt, g));
        if (g > 1e14 / ccnt)
            return false;
        g *= ccnt;
    }
    for (int i = 0; i < (int)v[cnode].size(); i++)
        if (v[cnode][i] != par) {
            if (!dfsLCM(v[cnode][i], cnode, cpro * ccnt))
                return false;
        }

    return true;
}
int main() {
    int i, n, x, y;
    cin >> n;
    LL s  = 0;
    for (i = 1; i <= n; i++) {
        cin >> a[i];
        s += a[i];
    }
    for (i = 1; i < n; i++) {
        cin >> x >> y;
        v[x].PB(y);
        v[y].PB(x);
    }
    LL lb = 0, ub = s, mid, ans = s;
    if (!dfsLCM(1)) ub = -1;
    else ub /= g;
    while (lb <= ub) {
        mid = (lb + ub) / 2;
        if (dfs(1, mid * g)) {
            ans = mid * g;
            lb = mid + 1;
        } else {
            ub = mid - 1;
        }
    }
    cout << s - ans << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define LET(x, a)  __typeof(a) x(a)
#define TR(v, it) for(LET(it, v.begin()); it != v.end(); it++)
#define si(x) scanf("%d",&x)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 10000000000000LL
#define MOD 1000000007
#define SET(x,y) memset(x,y,sizeof(x));
#define LL long long int
#define ULL unsigned LL
#define PII pair<int, int>

LL a[200005];
vector<LL> v[200004];
bool dfs(LL cnode, LL napp, LL par = -1) {
    LL ccnt = v[cnode].size();
    if (par != -1)
        ccnt --;
    if (ccnt == 0)
        return a[cnode] >= napp;
    if (napp % ccnt != 0)
        assert(false);
    bool ret = true;
    for (LL i = 0; i < (LL)v[cnode].size(); i++)
        if (v[cnode][i] != par)
            ret &= dfs(v[cnode][i], napp / ccnt, cnode);
    return ret;
}
LL g = 0;
bool dfsLCM(LL cnode, LL par = -1, LL cpro = 1) {
    LL ccnt = v[cnode].size();
    if (par != -1)
        ccnt --;
    if (ccnt == 0)
        return true;
    cpro *= ccnt;
    if (cpro > INF)
        return false;
    if (g == 0)
        g = cpro;
    else {
        g /= __gcd(cpro, g);
        if (g > INF / cpro) {
            g *= cpro;
            return false;
        }
        g *= cpro;
    }
    for (LL i = 0; i < (LL)v[cnode].size(); i++)
        if (v[cnode][i] != par) {
            if (!dfsLCM(v[cnode][i], cnode, cpro))
                return false;
        }

    return true;
}
int main() {
    LL i, n, x, y;
    cin >> n;
    LL s = 0;
    for (i = 1; i <= n; i++) {
        cin >> a[i];
        s += a[i];
    }
    for (i = 1; i < n; i++) {
        cin >> x >> y;
        v[x].PB(y);
        v[y].PB(x);
    }
    LL lb = 0, ub = s, mid, ans = s;
    if (!dfsLCM(1)) ub = -1;
    else ub /= g;
    while (lb <= ub) {
        mid = (lb + ub) / 2;
        if (dfs(1, mid * g)) {
            ans = mid * g;
            lb = mid + 1;
        } else {
            ub = mid - 1;
        }
    }
    cout << s - ans << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define LET(x, a)  __typeof(a) x(a)
#define TR(v, it) for(LET(it, v.begin()); it != v.end(); it++)
#define si(x) scanf("%d",&x)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 10000000000000LL
#define MOD 1000000007
#define SET(x,y) memset(x,y,sizeof(x));
#define LL long long int
#define ULL unsigned LL
#define PII pair<int, int>

LL a[200005];
vector<LL> v[200004];
bool dfs(LL cnode, LL napp, LL par = -1) {
    LL ccnt = v[cnode].size();
    if (par != -1)
        ccnt --;
    if (ccnt == 0)
        return a[cnode] >= napp;
    if (napp % ccnt != 0)
        assert(false);
    bool ret = true;
    for (LL i = 0; i < (LL)v[cnode].size(); i++)
        if (v[cnode][i] != par)
            ret &= dfs(v[cnode][i], napp / ccnt, cnode);
    return ret;
}
LL g = 0;
int n;
bool dfsLCM(LL cnode, LL par = -1, LL cpro = 1) {
    LL ccnt = v[cnode].size();
    if (par != -1)
        ccnt --;
    if (ccnt == 0)
        return true;
    cpro *= ccnt;
    if (cpro > INF)
        return false;
    if (g == 0)
        g = cpro;
    else {
        g /= __gcd(cpro, g);
        if (g > INF / cpro) {
            if (n == 100000) {
                cout << cnode << "   " << cpro << "  " << ccnt << endl;
                cout << g << " " << g * cpro << endl;
            }
            return false;
        }
        g *= cpro;
    }
    for (LL i = 0; i < (LL)v[cnode].size(); i++)
        if (v[cnode][i] != par) {
            if (!dfsLCM(v[cnode][i], cnode, cpro))
                return false;
        }

    return true;
}
int main() {
    LL i, x, y;
    cin >> n;
    LL s = 0;
    for (i = 1; i <= n; i++) {
        cin >> a[i];
        s += a[i];
    }
    for (i = 1; i < n; i++) {
        cin >> x >> y;
        v[x].PB(y);
        v[y].PB(x);
    }
    LL lb = 0, ub = s, mid, ans = s;
    if (!dfsLCM(1)) ub = -1;
    else ub /= g;
    if (n == 100000)
        cout << g << "  " << ub << endl;
    while (lb <= ub) {
        mid = (lb + ub) / 2;
        if (dfs(1, mid * g)) {
            ans = mid * g;
            lb = mid + 1;
        } else {
            ub = mid - 1;
        }
    }
    cout << s - ans << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define LET(x, a)  __typeof(a) x(a)
#define TR(v, it) for(LET(it, v.begin()); it != v.end(); it++)
#define si(x) scanf("%d",&x)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 10000000000000LL
#define MOD 1000000007
#define SET(x,y) memset(x,y,sizeof(x));
#define LL long long int
#define ULL unsigned LL
#define PII pair<int, int>

LL a[200005];
vector<LL> v[200004];
bool dfs(LL cnode, LL napp, LL par = -1) {
    LL ccnt = v[cnode].size();
    if (par != -1)
        ccnt --;
    if (ccnt == 0)
        return a[cnode] >= napp;
    if (napp % ccnt != 0)
        assert(false);
    bool ret = true;
    for (LL i = 0; i < (LL)v[cnode].size(); i++)
        if (v[cnode][i] != par)
            ret &= dfs(v[cnode][i], napp / ccnt, cnode);
    return ret;
}
LL g = 0;
int n;
bool dfsLCM(LL cnode, LL par = -1, LL cpro = 1) {
    LL ccnt = v[cnode].size();
    if (par != -1)
        ccnt --;
    if (ccnt == 0)
        return true;
    LL ppro = cpro;
    cpro *= ccnt;
    if (cpro > INF)
        return false;
    if (g == 0)
        g = cpro;
    else {
        g /= __gcd(cpro, g);
        if (g > INF / cpro) {
            return false;
        }
        g *= cpro;
    }
    for (LL i = 0; i < (LL)v[cnode].size(); i++)
        if (v[cnode][i] != par) {
            if (!dfsLCM(v[cnode][i], cnode, cpro))
                return false;
        }

    return true;
}
int main() {
    LL i, x, y;
    cin >> n;
    LL s = 0;
    for (i = 1; i <= n; i++) {
        cin >> a[i];
        s += a[i];
    }
    for (i = 1; i < n; i++) {
        cin >> x >> y;
        v[x].PB(y);
        v[y].PB(x);
    }
    LL lb = 0, ub = s, mid, ans = s;
    if (!dfsLCM(1)) ub = -1;
    else ub /= g;
    if (s >= INF)
        cout << s << endl;
    while (lb <= ub) {
        mid = (lb + ub) / 2;
        if (dfs(1, mid * g)) {
            ans = mid * g;
            lb = mid + 1;
        } else {
            ub = mid - 1;
        }
    }
    cout << s - ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;

#define block 320
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(ll i = a; i<=b; ++i)
#define NFOR(i,a,b) for(ll i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
//const ll INF = 1e18;
const ll mod = 1e9+7;
//const ll N = 1e5 + 10;
inline ll add(ll x,ll y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline ll mul(ll x,ll y){
  x = (1LL * x * y) % mod;
  return x;
}

ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}

ll LCM(ll a, ll b)
{
	ll c = gcd(a,b);
	return (a*b)/c;
}

int main()
{
	fast;
	ll n;
	cin>>n;
	ll a[n+1];
	int flag = 1;
	FOR(i,1,n){cin>>a[i];}
	vector<ll>v[n+1];
	FOR(i,1,n-1)
	{
		ll x,y;cin>>x>>y;
		v[x].pb(y);
		v[y].pb(x);
	}
	FOR(i,2,n)
	if(v[i].size()==1 && a[i]==0)flag=0;
	if(flag)
	{
	ll val[n+1];
	FOR(i,1,n)val[i]=1;
	queue<ll>q;
	q.push(1);
	ll vis[n+1]={0};
	while(!q.empty())
	{
		ll u = q.front();
		q.pop();
		vis[u]=1;
		if(v[u].size()>0)
		{
			ll l;
			if(u==1)l = v[u].size();
			else l = v[u].size()-1;
			FOR(i,0,v[u].size()-1)
			{
				if(vis[v[u][i]]==0)
				{
					val[v[u][i]]=l*val[u];
					q.push(v[u][i]);
				}
			}
		}
	}
	// FOR(i,1,n)cout << val[i] << " ";cout << "\n";
	vector<ii>vp;
	FOR(i,1,n)
	{
		if(v[i].size()==1 && i!=1)
		{
			vp.pb(mp(val[i],i));
		}
	}
	//FOR(i,0,vp.size()-1)cout << vp[i].F << "  " << vp[i].S << "\n";
	ll lcm = 1;
	ll minv = 1e18;
	if(vp.size()>0)
	{
		FOR(i,0,vp.size()-1)
		{
			ii x = vp[i];
			ll b = x.F*a[x.S];
			if(b<minv)minv=b;
			lcm = LCM(lcm,x.F);
		}
	}
	// cout << lcm << " " << minv << "\n";
	ll mul = 0;
	ll ans = lcm;
	while((ans*mul)<=minv)
	{
		mul++;
	}
	mul--;
	ans*=mul;
	//cout << ans << "\n";
	ll sum = 0;
	FOR(i,1,n)
	{
		if(v[i].size()==1 && i!=1)
		{
			sum+= (a[i]-(ans/val[i]));
		}
	}
	cout << sum;
	}
	else
	{
		ll sum = 0;
		FOR(i,1,n)sum+=a[i];
		cout << sum;
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;

#define block 320
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(ll i = a; i<=b; ++i)
#define NFOR(i,a,b) for(ll i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
//const ll INF = 1e18;
const ll mod = 1e9+7;
//const ll N = 1e5 + 10;
inline ll add(ll x,ll y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline ll mul(ll x,ll y){
  x = (1LL * x * y) % mod;
  return x;
}

ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}

ll LCM(ll a, ll b)
{
	ll c = gcd(a,b);
	return (a*b)/c;
}

int main()
{
	fast;
	ll n;
	cin>>n;
	ll a[n+1];
	FOR(i,1,n)cin>>a[i];
	vector<ll>v[n+1];
	FOR(i,1,n-1)
	{
		ll x,y;cin>>x>>y;
		v[x].pb(y);
		v[y].pb(x);
	}
	ll val[n+1];
	FOR(i,1,n)val[i]=1;
	queue<ll>q;
	q.push(1);
	ll vis[n+1]={0};
	while(!q.empty())
	{
		ll u = q.front();
		q.pop();
		vis[u]=1;
		if(v[u].size()>0)
		{
			ll l;
			if(u==1)l = v[u].size();
			else l = v[u].size()-1;
			FOR(i,0,v[u].size()-1)
			{
				if(vis[v[u][i]]==0)
				{
					val[v[u][i]]=l*val[u];
					q.push(v[u][i]);
				}
			}
		}
	}
	// FOR(i,1,n)cout << val[i] << " ";cout << "\n";
	vector<ii>vp;
	FOR(i,1,n)
	{
		if(v[i].size()==1)
		{
			vp.pb(mp(val[i],i));
		}
	}
	// FOR(i,0,vp.size()-1)cout << vp[i].F << "  " << vp[i].S << "\n";
	ll lcm = 1;
	ll minv = 1e18;
	FOR(i,0,vp.size()-1)
	{
		ii x = vp[i];
		ll b = x.F*a[x.S];
		if(b<minv)minv=b;
		lcm = LCM(lcm,x.F);
	}
	// cout << lcm << " " << minv << "\n";
	ll mul = 0;
	ll ans = lcm;
	while((ans*mul)<=minv)
	{
		mul++;
	}
	mul--;
	ans*=mul;
	// cout << ans << "\n";
	ll sum = 0;
	FOR(i,1,n)
	{
		if(v[i].size()==1)
		{
			sum+= (a[i]-(ans/val[i]));
		}
	}
	cout << sum;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;

#define block 320
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(ll i = a; i<=b; ++i)
#define NFOR(i,a,b) for(ll i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
//const ll INF = 1e18;
const ll mod = 1e9+7;
//const ll N = 1e5 + 10;
inline ll add(ll x,ll y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline ll mul(ll x,ll y){
  x = (1LL * x * y) % mod;
  return x;
}

ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}

ll LCM(ll a, ll b)
{
	ll c = gcd(a,b);
	return (a*b)/c;
}

int main()
{
	fast;
	ll n;
	cin>>n;
	ll a[n+1];
	FOR(i,1,n)cin>>a[i];
	vector<ll>v[n+1];
	FOR(i,1,n-1)
	{
		ll x,y;cin>>x>>y;
		v[x].pb(y);
		v[y].pb(x);
	}
	ll val[n+1];
	FOR(i,1,n)val[i]=1;
	queue<ll>q;
	q.push(1);
	ll vis[n+1]={0};
	while(!q.empty())
	{
		ll u = q.front();
		q.pop();
		vis[u]=1;
		if(v[u].size()>0)
		{
			ll l;
			if(u==1)l = v[u].size();
			else l = v[u].size()-1;
			FOR(i,0,v[u].size()-1)
			{
				if(vis[v[u][i]]==0)
				{
					val[v[u][i]]=l*val[u];
					q.push(v[u][i]);
				}
			}
		}
	}
	// FOR(i,1,n)cout << val[i] << " ";cout << "\n";
	vector<ii>vp;
	FOR(i,1,n)
	{
		if(v[i].size()==1 && i!=1)
		{
			vp.pb(mp(val[i],i));
		}
	}
	//FOR(i,0,vp.size()-1)cout << vp[i].F << "  " << vp[i].S << "\n";
	ll lcm = 1;
	ll minv = 1e18;
	FOR(i,0,vp.size()-1)
	{
		ii x = vp[i];
		ll b = x.F*a[x.S];
		if(b<minv)minv=b;
		lcm = LCM(lcm,x.F);
	}
	// cout << lcm << " " << minv << "\n";
	ll mul = 0;
	ll ans = lcm;
	while((ans*mul)<=minv)
	{
		mul++;
	}
	mul--;
	ans*=mul;
	//cout << ans << "\n";
	ll sum = 0;
	FOR(i,1,n)
	{
		if(v[i].size()==1 && i!=1)
		{
			sum+= (a[i]-(ans/val[i]));
		}
	}
	cout << sum;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;

#define block 320
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(ll i = a; i<=b; ++i)
#define NFOR(i,a,b) for(ll i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
//const ll INF = 1e18;
const ll mod = 1e9+7;
//const ll N = 1e5 + 10;
inline ll add(ll x,ll y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline ll mul(ll x,ll y){
  x = (1LL * x * y) % mod;
  return x;
}

ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}

ll LCM(ll a, ll b)
{
	ll c = gcd(a,b);
	return (a*b)/c;
}

int main()
{
	fast;
	ll n;
	cin>>n;
	ll a[n+1];
	int flag = 1;
	FOR(i,1,n){cin>>a[i];}
	vector<ll>v[n+1];
	FOR(i,1,n-1)
	{
		ll x,y;cin>>x>>y;
		v[x].pb(y);
		v[y].pb(x);
	}
	FOR(i,2,n)
	if(v[i].size()==1 && a[i]==0)flag=0;
	if(flag)
	{
	ll val[n+1];
	FOR(i,1,n)val[i]=1;
	queue<ll>q;
	q.push(1);
	ll vis[n+1]={0};
	int flg2 = 1;
	while(!q.empty())
	{
		ll u = q.front();
		q.pop();
		vis[u]=1;
		if(val[u]>1e14)
		{
			flg2=0;break;
		}
		if(v[u].size()>0)
		{
			ll l;
			if(u==1)l = v[u].size();
			else l = v[u].size()-1;
			FOR(i,0,v[u].size()-1)
			{
				if(vis[v[u][i]]==0)
				{
					val[v[u][i]]=l*val[u];
					q.push(v[u][i]);
				}
			}
		}
	}
	if(flg2)
	{
	// FOR(i,1,n)cout << val[i] << " ";cout << "\n";
	vector<ii>vp;
	FOR(i,1,n)
	{
		if(v[i].size()==1 && i!=1)
		{
			vp.pb(mp(val[i],i));
		}
	}
	//FOR(i,0,vp.size()-1)cout << vp[i].F << "  " << vp[i].S << "\n";
	ll lcm = 1;
	ll minv = 1e18;
	if(vp.size()>0)
	{
		FOR(i,0,vp.size()-1)
		{
			ii x = vp[i];
			ll b = x.F*a[x.S];
			if(b<minv)minv=b;
			lcm = LCM(lcm,x.F);
		}
	}
	// cout << lcm << " " << minv << "\n";
	ll mul = 0;
	ll ans = lcm;
	while((ans*mul)<=minv)
	{
		mul++;
	}
	mul--;
	ans*=mul;
	//cout << ans << "\n";
	ll sum = 0;
	FOR(i,1,n)
	{
		if(v[i].size()==1 && i!=1)
		{
			sum+= (a[i]-(ans/val[i]));
		}
	}
	cout << sum;
	}
	else
	{
		ll sum = 0;
		FOR(i,1,n)sum+=a[i];
		cout << sum;
	}
	}
	else
	{
		ll sum = 0;
		FOR(i,1,n)sum+=a[i];
		cout << sum;
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;

#define block 320
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(ll i = a; i<=b; ++i)
#define NFOR(i,a,b) for(ll i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
//const ll INF = 1e18;
const ll mod = 1e9+7;
//const ll N = 1e5 + 10;
inline ll add(ll x,ll y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline ll mul(ll x,ll y){
  x = (1LL * x * y) % mod;
  return x;
}

ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}

ll LCM(ll a, ll b)
{
	ll c = gcd(a,b);
	return (a*b)/c;
}

int main()
{
	fast;
	ll n;
	cin>>n;
	ll a[n+1];
	FOR(i,1,n)cin>>a[i];
	vector<ll>v[n+1];
	FOR(i,1,n-1)
	{
		ll x,y;cin>>x>>y;
		v[x].pb(y);
		v[y].pb(x);
	}
	ll val[n+1];
	FOR(i,1,n)val[i]=1;
	queue<ll>q;
	q.push(1);
	ll vis[n+1]={0};
	while(!q.empty())
	{
		ll u = q.front();
		q.pop();
		vis[u]=1;
		if(v[u].size()>0)
		{
			ll l;
			if(u==1)l = v[u].size();
			else l = v[u].size()-1;
			FOR(i,0,v[u].size()-1)
			{
				if(vis[v[u][i]]==0)
				{
					val[v[u][i]]=l*val[u];
					q.push(v[u][i]);
				}
			}
		}
	}
	// FOR(i,1,n)cout << val[i] << " ";cout << "\n";
	vector<ii>vp;
	FOR(i,1,n)
	{
		if(v[i].size()==1 && i!=1)
		{
			vp.pb(mp(val[i],i));
		}
	}
	//FOR(i,0,vp.size()-1)cout << vp[i].F << "  " << vp[i].S << "\n";
	ll lcm = 1;
	ll minv = 1e18;
	if(vp.size()>0)
	{
		FOR(i,0,vp.size()-1)
		{
			ii x = vp[i];
			ll b = x.F*a[x.S];
			if(b<minv)minv=b;
			lcm = LCM(lcm,x.F);
		}
	}
	// cout << lcm << " " << minv << "\n";
	ll mul = 0;
	ll ans = lcm;
	while((ans*mul)<=minv)
	{
		mul++;
	}
	mul--;
	ans*=mul;
	//cout << ans << "\n";
	ll sum = 0;
	FOR(i,1,n)
	{
		if(v[i].size()==1 && i!=1)
		{
			sum+= (a[i]-(ans/val[i]));
		}
	}
	cout << sum;

	return 0;
}


#include"bits/stdc++.h"
using namespace std;
typedef long long LL;
const LL INF = 1e18;
int n;
const int maxn = 2e5 + 10;
vector<int> E[maxn];
LL d[maxn];
LL a[maxn];
LL sum[maxn];
int vis[maxn];
LL gcd(LL a, LL b)
{
    if(a % b == 0) return b;
    return gcd(b, a % b);
}
LL lcm(LL a, LL b)
{
    return a / gcd(a, b) * b;
}
void dfs(int u)
{
    vis[u] = 1;
    sum[u] = a[u];
    LL temlcm = 1;
    LL cnt = 0;
    for(auto i : E[u]){
        if(!vis[i]){
            dfs(i);
            cnt ++;
            sum[u] += sum[i];
            temlcm = lcm(temlcm, d[i]);
        }
    }
    if(cnt == 0) {
        d[u] = 1;
    }
    else
        d[u] = temlcm * cnt;
}
LL ans = 0;
void dfs2(int u)
{
    vis[u] = 1;
    LL tem = INF;
    LL cnt = 0;
    vector<int> son;
    for(auto i : E[u]){
        if(!vis[i]){
            dfs2(i);
            cnt ++;
            son.push_back(i);
            tem = min(tem, sum[i]);
        }
    }
    if(cnt == 0) return;
    LL t = d[u] / cnt;
    LL x = tem / t * t;
    LL temsum = 0;
    for(auto i : son){
        temsum += sum[i];
    }
    ans += temsum - cnt * x;
    sum[u] = cnt * x;
    if(n == 1e5){
        cout << ans << endl;
    }
}
int main()
{
    cin >> n;
    for(int i = 1; i <= n; i ++){
        cin >> a[i];
        d[i] = 1;
    }
    int x, y;
    for(int i = 1; i < n; i ++){
        cin >> x >> y;
        E[x].push_back(y);
        E[y].push_back(x);
    }
    memset(vis, 0, sizeof(vis));
    dfs(1);
    memset(vis, 0, sizeof(vis));
    dfs2(1);
    cout << ans <<endl;
    return 0;
}


#include"bits/stdc++.h"
using namespace std;
typedef long long LL;
const LL INF = 1e18;
int n;
const int maxn = 2e5 + 10;
vector<int> E[maxn];
LL d[maxn];
LL a[maxn];
LL sum[maxn];
int vis[maxn];
LL gcd(LL a, LL b)
{
    if(a % b == 0) return b;
    return gcd(b, a % b);
}
LL lcm(LL a, LL b)
{
    return a / gcd(a, b) * b;
}
void dfs(int u)
{
    vis[u] = 1;
    sum[u] = a[u];
    LL temlcm = 1;
    LL cnt = 0;
    for(auto i : E[u]){
        if(!vis[i]){
            dfs(i);
            cnt ++;
            sum[u] += sum[i];
            temlcm = lcm(temlcm, d[i]);
        }
    }
    if(cnt == 0) {
        d[u] = 1;
    }
    else
        d[u] = temlcm * cnt;
}
LL ans = 0;
void dfs2(int u)
{
    vis[u] = 1;
    LL cnt = 0;
    LL tem;
    vector<int> son;
    son.clear();
    for(auto i : E[u]){
        if(!vis[i]){
            dfs2(i);
            cnt ++;
            son.push_back(i);
            if(cnt == 1){
                tem = sum[i];
            }
            else{
                tem = min(tem, sum[i]);
            }
        }
    }
    if(cnt == 0) return;
    LL t = d[u] / cnt;
    LL x = tem / t * t;
    LL temsum = 0;
    for(auto i : son){
        temsum += sum[i];
    }
    ans += temsum - cnt * x;
    sum[u] = cnt * x;
}
int main()
{
    cin >> n;
    for(int i = 1; i <= n; i ++){
        cin >> a[i];
        d[i] = 1;
    }
    int x, y;
    for(int i = 1; i < n; i ++){
        cin >> x >> y;
        E[x].push_back(y);
        E[y].push_back(x);
    }
    memset(vis, 0, sizeof(vis));
    dfs(1);
    memset(vis, 0, sizeof(vis));
    dfs2(1);
    cout << ans <<endl;
    return 0;
}


#include"bits/stdc++.h"
using namespace std;
typedef long long LL;
const LL INF = 2e13;
const int maxn = 1e5 + 10;
vector<int> E[maxn];
LL d[maxn];
LL a[maxn];
LL sum[maxn];
int vis[maxn];
LL gcd(LL a, LL b)
{
    if(a % b == 0) return b;
    return gcd(b, a % b);
}
LL lcm(LL a, LL b)
{
    return a / gcd(a, b) * b;
}
void dfs(int u)
{
    vis[u] = 1;
    sum[u] = a[u];
    LL temlcm = 1;
    LL cnt = 0;
    for(auto i : E[u]){
        if(!vis[i]){
            dfs(i);
            cnt ++;
            sum[u] += sum[i];
            temlcm = lcm(temlcm, d[i]);
        }
    }
    if(cnt == 0) cnt ++;
    d[u] = temlcm * cnt;
}
LL ans = 0;
void dfs2(int u)
{
    vis[u] = 1;
    LL tem = INF;
    LL cnt = 0;
    vector<int> son;
    for(auto i : E[u]){
        if(!vis[i]){
            dfs2(i);
            cnt ++;
            son.push_back(i);
            tem = min(tem, sum[i]);
        }
    }
    if(cnt == 0) return;
    LL t = d[u] / cnt;
    LL x = tem / t * t;
    LL temsum = 0;
    for(auto i : son){
        temsum += sum[i];
    }
    ans += temsum - cnt * x;
    sum[u] = cnt * x;
}
int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i ++){
        cin >> a[i];
        d[i] = 1ll;
    }
    int x, y;
    for(int i = 1; i < n; i ++){
        cin >> x >> y;
        E[x].push_back(y);
        E[y].push_back(x);
    }
    memset(vis, 0, sizeof(vis));
    dfs(1);
    memset(vis, 0, sizeof(vis));
    dfs2(1);
    cout << ans <<endl;
    return 0;
}


#include"bits/stdc++.h"
using namespace std;
typedef long long LL;
const LL INF = 1e18;
const int maxn = 2e5 + 10;
vector<int> E[maxn];
LL d[maxn];
LL a[maxn];
LL sum[maxn];
int vis[maxn];
LL gcd(LL a, LL b)
{
    if(a % b == 0) return b;
    return gcd(b, a % b);
}
LL lcm(LL a, LL b)
{
    return a / gcd(a, b) * b;
}
void dfs(int u)
{
    vis[u] = 1;
    sum[u] = a[u];
    LL temlcm = 1;
    LL cnt = 0;
    for(auto i : E[u]){
        if(!vis[i]){
            dfs(i);
            cnt ++;
            sum[u] += sum[i];
            temlcm = lcm(temlcm, d[i]);
        }
    }
    if(cnt == 0) cnt ++;
    d[u] = temlcm * cnt;
}
LL ans = 0;
void dfs2(int u)
{
    vis[u] = 1;
    LL tem = INF;
    LL cnt = 0;
    vector<int> son;
    for(auto i : E[u]){
        if(!vis[i]){
            dfs2(i);
            cnt ++;
            son.push_back(i);
            tem = min(tem, sum[i]);
        }
    }
    if(cnt == 0) return;
    LL t = d[u] / cnt;
    LL x = tem / t * t;
    LL temsum = 0;
    for(auto i : son){
        temsum += sum[i];
    }
    ans += temsum - cnt * x;
    sum[u] = cnt * x;
}
int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i ++){
        cin >> a[i];
        d[i] = 1ll;
    }
    int x, y;
    for(int i = 1; i < n; i ++){
        cin >> x >> y;
        E[x].push_back(y);
        E[y].push_back(x);
    }
    memset(vis, 0, sizeof(vis));
    dfs(1);
    memset(vis, 0, sizeof(vis));
    dfs2(1);
    cout << ans <<endl;
    return 0;
}


#include"bits/stdc++.h"
using namespace std;
typedef long long LL;
const int INF = 2e13;
const int maxn = 1e5 + 10;
vector<int> E[maxn];
LL d[maxn];
LL a[maxn];
LL sum[maxn];
LL gcd(LL a, LL b)
{
    if(a % b == 0) return b;
    return gcd(b, a % b);
}
LL lcm(LL a, LL b)
{
    return a / gcd(a, b) * b;
}
void dfs(int u)
{
    sum[u] = a[u];
    LL k = E[u].size();
    for(auto i : E[u]){
        dfs(i);
        sum[u] += sum[i];
    }
    if(k == 0) k ++;
    LL temlcm = 1;
    for(auto i : E[u]){
        temlcm = lcm(temlcm, d[i]);
    }
    d[u] = temlcm * k;
}
LL ans = 0;
void dfs2(int u)
{
    LL tem = INF;
    LL k = (LL)E[u].size();
    if(k == 0) {
        return;
    }
    for(auto i : E[u]){
        dfs2(i);
        tem = min(tem, sum[i]);
    }
    LL t = d[u] / k;
    LL x = tem / t * t;
    LL temsum = 0;
    for(auto i : E[u]){
        temsum += sum[i];
    }
    ans += temsum - k * x;
    sum[u] = k * x;
    //cout << ans << endl;
}
int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i ++){
        cin >> a[i];
        d[i] = 1ll;
    }
    int x, y;
    for(int i = 1; i < n; i ++){
        cin >> x >> y;
        E[x].push_back(y);
    }
    dfs(1);
    dfs2(1);
    cout << ans <<endl;
    return 0;
}


#include"bits/stdc++.h"
using namespace std;
typedef long long LL;
const LL INF = 1e18;
int n;
const int maxn = 2e5 + 10;
vector<int> E[maxn];
LL d[maxn];
LL a[maxn];
LL sum[maxn];
int vis[maxn];
LL gcd(LL a, LL b)
{
    if(a % b == 0) return b;
    return gcd(b, a % b);
}
LL lcm(LL a, LL b)
{
    return a / gcd(a, b) * b;
}
LL tol = 0;
void dfs(int u)
{
    vis[u] = 1;
    sum[u] = a[u];
    LL temlcm = 1;
    LL cnt = 0;
    for(auto i : E[u]){
        if(!vis[i]){
            dfs(i);
            cnt ++;
            sum[u] += sum[i];
            temlcm = lcm(temlcm, d[i]);
        }
    }
    if(cnt == 0) {
        d[u] = 1;
    }
    else{
        if(temlcm * cnt > tol){
            cout << tol << endl;
            exit(0);
        }
        d[u] = temlcm * cnt;
    }
}
LL ans = 0;
void dfs2(int u)
{
    vis[u] = 1;
    LL cnt = 0;
    LL tem;
    vector<int> son;
    son.clear();
    for(auto i : E[u]){
        if(!vis[i]){
            dfs2(i);
            cnt ++;
            son.push_back(i);
            if(cnt == 1){
                tem = sum[i];
            }
            else{
                tem = min(tem, sum[i]);
            }
        }
    }
    if(cnt == 0) return;
    LL t = d[u] / cnt;
    LL x = tem / t * t;
    LL temsum = 0;
    for(auto i : son){
        temsum += sum[i];
    }
    ans += temsum - cnt * x;
    sum[u] = cnt * x;
}
int main()
{
    cin >> n;
    for(int i = 1; i <= n; i ++){
        cin >> a[i];
        tol += a[i];
        d[i] = 1;
    }
    int x, y;
    for(int i = 1; i < n; i ++){
        cin >> x >> y;
        E[x].push_back(y);
        E[y].push_back(x);
    }
    memset(vis, 0, sizeof(vis));
    dfs(1);
    memset(vis, 0, sizeof(vis));
    dfs2(1);
    cout << ans <<endl;
    return 0;
}


#include"bits/stdc++.h"
using namespace std;
typedef long double LL;
typedef long long LL2;
const LL INF = 1e18;
int n;
const int maxn = 2e5 + 10;
vector<int> E[maxn];
LL d[maxn];
LL a[maxn];
LL sum[maxn];
int vis[maxn];
LL gcd(LL a, LL b)
{
    if((LL2)a % (LL2)b == 0) return b;
    return gcd(b, (LL2)a % (LL2)b);
}
LL lcm(LL a, LL b)
{
    return a / gcd(a, b) * b;
}
LL tol = 0;
void dfs(int u)
{
    vis[u] = 1;
    sum[u] = a[u];
    LL temlcm = 1;
    LL cnt = 0;
    for(auto i : E[u]){
        if(!vis[i]){
            dfs(i);
            cnt ++;
            sum[u] += sum[i];
            temlcm = lcm(temlcm, d[i]);
        }
    }
    if(cnt == 0) {
        d[u] = 1;
    }
    else
        d[u] = temlcm * cnt;
}
LL ans = 0;
void dfs2(int u)
{
    vis[u] = 1;
    LL cnt = 0;
    LL tem;
    vector<int> son;
    son.clear();
    for(auto i : E[u]){
        if(!vis[i]){
            dfs2(i);
            cnt ++;
            son.push_back(i);
            if(cnt == 1){
                tem = sum[i];
            }
            else{
                tem = min(tem, sum[i]);
            }
        }
    }
    if(cnt == 0) return;
    LL t = d[u] / cnt;
    LL x = tem / t * t;
    LL temsum = 0;
    for(auto i : son){
        temsum += sum[i];
    }
    ans += temsum - cnt * x;
    sum[u] = cnt * x;
}
int main()
{
    cin >> n;
    for(int i = 1; i <= n; i ++){
        cin >> a[i];
        d[i] = 1;
    }
    int x, y;
    for(int i = 1; i < n; i ++){
        cin >> x >> y;
        E[x].push_back(y);
        E[y].push_back(x);
    }
    memset(vis, 0, sizeof(vis));
    dfs(1);
    memset(vis, 0, sizeof(vis));
    dfs2(1);
    cout << ans <<endl;
    return 0;
}


#include"bits/stdc++.h"
using namespace std;
typedef long long LL;
const int INF = 2e13;
const int maxn = 1e5 + 10;
vector<int> E[maxn];
LL d[maxn];
LL a[maxn];
LL sum[maxn];
int vis[maxn];
LL gcd(LL a, LL b)
{
    if(a % b == 0) return b;
    return gcd(b, a % b);
}
LL lcm(LL a, LL b)
{
    return a / gcd(a, b) * b;
}
void dfs(int u)
{
    vis[u] = 1;
    sum[u] = a[u];
    LL temlcm = 1;
    LL cnt = 0;
    for(auto i : E[u]){
        if(!vis[i]){
            dfs(i);
            cnt ++;
            sum[u] += sum[i];
            temlcm = lcm(temlcm, d[i]);
        }
    }
    if(cnt == 0) cnt ++;
    d[u] = temlcm * cnt;
}
LL ans = 0;
void dfs2(int u)
{
    vis[u] = 1;
    LL tem = INF;
    LL cnt = 0;
    vector<int> son;
    for(auto i : E[u]){
        if(!vis[i]){
            dfs2(i);
            cnt ++;
            son.push_back(i);
            tem = min(tem, sum[i]);
        }
    }
    if(cnt == 0) return;
    LL t = d[u] / cnt;
    LL x = tem / t * t;
    LL temsum = 0;
    for(auto i : son){
        temsum += sum[i];
//        cout << i << ' ' << sum[i] << endl;
    }
    ans += temsum - cnt * x;
    sum[u] = cnt * x;
}
int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i ++){
        cin >> a[i];
        d[i] = 1ll;
    }
    int x, y;
    for(int i = 1; i < n; i ++){
        cin >> x >> y;
        E[x].push_back(y);
        E[y].push_back(x);
    }
    memset(vis, 0, sizeof(vis));
    dfs(1);
    memset(vis, 0, sizeof(vis));
    dfs2(1);
    cout << ans <<endl;
    return 0;
}


//In the name of Allah

#include <bits/stdc++.h>

#define ll long long
#define ld long double

using namespace std;

const int MAXN=100*100*10*2+10;
ll t[MAXN],mn[MAXN],sib[MAXN];
bool mark[MAXN];
vector <ll>a[MAXN];

void dfs(int v){

    mark[v]=true;

    ll p=1,gcd=1,kmm=1,cnt=0 ,m=1e+17,tt;
    bool flag=false;
    vector <int>x;

    for(int i=0;i<a[v].size();i++)
        if(mark[a[v][i]] == false){
            dfs(a[v][i]);
            x.push_back(a[v][i]);
        }

    for(int i=0;i<x.size();i++){
        m=min(m,sib[x[i]]);
        if(i==0)
            kmm=gcd=t[x[i]];
        else{
            kmm=(kmm*t[x[i]])/__gcd(gcd,t[x[i]]);
            gcd=__gcd(gcd,t[x[i]]);
        }
    }
    if(x.size()){
        t[v]=kmm*x.size();
        sib[v]=((m/kmm)*kmm)*x.size();
        for(int i=0;i<x.size();i++)
            sib[x[i]]=(m/kmm)*kmm;
        mn[v]=(m/kmm)*kmm;
    }

    //cerr<<"Vectex "<<v+1<<" Min in sons = "<<kmm<<" its apples = "<<x.size()<<" and lcm is = "<<t[v]<<endl;

}

int main(){
    int n;
    cin>>n;
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>sib[i];
        sum+=sib[i];
        t[i]=1;
        mn[i]=sib[i];
    }
    int x,y;
    for(int i=0;i<n-1;i++){
        cin>>x>>y;
        a[--x].push_back(--y);
        a[y].push_back(x);
    }
    dfs(0);
    cout<<sum-sib[0]<<endl;
    return 0;
}


//In the name of Allah

#include <bits/stdc++.h>

#define ll long long
#define ld long double

using namespace std;

const int MAXN=100*100*10*2+10;
ll t[MAXN],mn[MAXN],sib[MAXN];
bool mark[MAXN];
vector <ll>a[MAXN];

void dfs(int v){
    //cerr<<v;
    mark[v]=true;

    ll p=1,gcd=1,kmm=1,m=1e+17,cnt=0;

    for(int i=0;i<a[v].size();i++)
        if(mark[a[v][i]] == false){
            dfs(a[v][i]);
            int u=a[v][i];
            m=min(m,sib[u]);
            kmm=kmm/__gcd(kmm,t[u])*t[u];
            cnt++;
        }
   //cerr<<sib[v]<<endl;
   if(a[v].size()!=1 or v==0){
        t[v]=max((ll)1,kmm*cnt);
        sib[v]=(m/kmm)*kmm*cnt;
    }
}

int main(){
    int n;
    cin>>n;
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>sib[i];
        sum+=sib[i];
        t[i]=1;
    }
    int x,y;
    for(int i=0;i<n-1;i++){
        cin>>x>>y;
        a[--x].push_back(--y);
        a[y].push_back(x);
    }
    dfs(0);
    cout<<sum-sib[0]<<endl;
    return 0;
}


//In the name of Allah

#include <bits/stdc++.h>

#define ll long long
#define ld long double

using namespace std;

const int MAXN=100*100*10*2+10;
ll t[MAXN],mn[MAXN],sib[MAXN];
bool mark[MAXN];
vector <ll>a[MAXN];

void dfs(int v){

    mark[v]=true;

    ll p=1,gcd=1,kmm=1,cnt=0 ,m=1e+17,tt;
    bool flag=false;
    vector <int>x;

    for(int i=0;i<a[v].size();i++)
        if(mark[a[v][i]] == false){
            dfs(a[v][i]);
            x.push_back(a[v][i]);
        }

    for(int i=0;i<x.size();i++){
        m=min(m,sib[x[i]]);
        if(i==0)
            kmm=gcd=t[x[i]];
        else{
            kmm=kmm/__gcd(gcd,t[x[i]])*t[x[i]];
            gcd=__gcd(gcd,t[x[i]]);
        }
    }
    if(x.size()){
        t[v]=kmm*x.size();
        sib[v]=((m/kmm)*kmm)*x.size();
        for(int i=0;i<x.size();i++)
            sib[x[i]]=(m/kmm)*kmm;
        mn[v]=(m/kmm)*kmm;
    }

    //cerr<<"Vectex "<<v+1<<" Min in sons = "<<kmm<<" its apples = "<<x.size()<<" and lcm is = "<<t[v]<<endl;

}

int main(){
    int n;
    cin>>n;
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>sib[i];
        sum+=sib[i];
        t[i]=1;
        mn[i]=sib[i];
    }
    int x,y;
    for(int i=0;i<n-1;i++){
        cin>>x>>y;
        a[--x].push_back(--y);
        a[y].push_back(x);
    }
    dfs(0);
    cout<<sum-sib[0]<<endl;
    return 0;
}


//In the name of Allah

#include <bits/stdc++.h>

#define ll long long
#define ld long double

using namespace std;

const int MAXN=100*100*10*2+10;
ll t[MAXN],mn[MAXN],sib[MAXN];
bool mark[MAXN];
vector <ll>a[MAXN];

void dfs(int v){

    mark[v]=true;

    ll p=1,gcd=1,kmm=1,cnt=0 ,m=1e+17;
    bool flag=false;
    vector <int>x;

    for(int i=0;i<a[v].size();i++)
        if(mark[a[v][i]] == false){
            dfs(a[v][i]);
            x.push_back(a[v][i]);
        }

    bool k=false;
    for(int i=0;i<x.size();i++){
        m=min(m,sib[x[i]]);
        if(__gcd(kmm,t[x[i]])==0){
        	kmm=0;
        	break;
        	k=true;
        }
		kmm=kmm/__gcd(kmm,t[x[i]])*t[x[i]];
    	//cerr<<kmm<<endl;
	}

    if(x.size() and !k){
        t[v]=kmm*x.size();
        sib[v]=((m/kmm)*kmm)*x.size();
        cout<<kmm<<endl;
		for(int i=0;i<x.size();i++)
            sib[x[i]]=(m/kmm)*kmm;
        mn[v]=(m/kmm)*kmm;
    }
    if(k)
    {
    	mn[v]=0;
    	t[v]=0;
    	sib[v]=0;
	}

    //cerr<<"Vectex "<<v+1<<" Min in sons = "<<kmm<<" its apples = "<<x.size()<<" and lcm is = "<<t[v]<<endl;

}

int main(){
    int n;
    cin>>n;
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>sib[i];
        sum+=sib[i];
        t[i]=1;
        mn[i]=sib[i];
    }
    int x,y;
    for(int i=0;i<n-1;i++){
        cin>>x>>y;
        a[--x].push_back(--y);
        a[y].push_back(x);
    }
    dfs(0);
    cout<<sum-sib[0]<<endl;
    return 0;
}


//In the name of Allah

#include <bits/stdc++.h>

#define ll long long
#define ld long double

using namespace std;

const int MAXN=100*100*10*2+10;
ll t[MAXN],mn[MAXN],sib[MAXN];
bool mark[MAXN];
vector <ll>a[MAXN];

void dfs(int v){

    mark[v]=true;

    ll p=1,gcd=1,kmm=1,cnt=0 ,m=1e+17;
    bool flag=false;
    vector <int>x;

    for(int i=0;i<a[v].size();i++)
        if(mark[a[v][i]] == false){
            dfs(a[v][i]);
            x.push_back(a[v][i]);
        }

    bool k=false;
    for(int i=0;i<x.size();i++){
        m=min(m,sib[x[i]]);
        if(__gcd(kmm,t[x[i]])==0){
        	kmm=0;
      		k=true;
	    	break;
        }
		kmm=kmm/__gcd(kmm,t[x[i]])*t[x[i]];
    	//cerr<<kmm<<endl;
	}

    if(x.size() and !k){
        t[v]=kmm*x.size();
        sib[v]=((m/kmm)*kmm)*x.size();
        //cout<<kmm<<endl;
		for(int i=0;i<x.size();i++)
            sib[x[i]]=(m/kmm)*kmm;
        mn[v]=(m/kmm)*kmm;
    }
    //if(k)
    //{
    //	mn[v]=0;
    //	t[v]=0;
    //	sib[v]=0;
	//}

    //cerr<<"Vectex "<<v+1<<" Min in sons = "<<kmm<<" its apples = "<<x.size()<<" and lcm is = "<<t[v]<<endl;

}

int main(){
    int n;
    cin>>n;
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>sib[i];
        sum+=sib[i];
        t[i]=1;
        mn[i]=sib[i];
    }
    int x,y;
    for(int i=0;i<n-1;i++){
        cin>>x>>y;
        a[--x].push_back(--y);
        a[y].push_back(x);
    }
    dfs(0);
    cout<<sum-sib[0]<<endl;
    return 0;
}


//In the name of Allah

#include <bits/stdc++.h>

#define ll long long
#define ld long double

using namespace std;

const int MAXN=100*100*10*2+10;
ll t[MAXN],mn[MAXN],sib[MAXN];
bool mark[MAXN];
vector <ll>a[MAXN];

void dfs(int v){

    mark[v]=true;

    ll p=1,gcd=1,kmm=1,cnt=0 ,m=1e+17;
    bool flag=false;
    vector <int>x;

    for(int i=0;i<a[v].size();i++)
        if(mark[a[v][i]] == false){
            dfs(a[v][i]);
            x.push_back(a[v][i]);
        }

    bool k=false;
    for(int i=0;i<x.size();i++){
        m=min(m,sib[x[i]]);
        if(__gcd(kmm,t[x[i]])==0){
        	kmm=0;
      		k=true;
	    	break;
        }
		kmm=kmm/__gcd(kmm,t[x[i]])*t[x[i]];
    	//cerr<<kmm<<endl;
	}

    if(x.size() and !k){
        t[v]=kmm*x.size();
        sib[v]=((m/kmm)*kmm)*x.size();
        //cout<<kmm<<endl;
		for(int i=0;i<x.size();i++)
            sib[x[i]]=(m/kmm)*kmm;
        mn[v]=(m/kmm)*kmm;
    }
    if(k)
    {
    	mn[v]=0;
		t[v]=0;
    	sib[v]=0;
	}

    //cerr<<"Vectex "<<v+1<<" Min in sons = "<<kmm<<" its apples = "<<x.size()<<" and lcm is = "<<t[v]<<endl;

}

int main(){
    int n;
    cin>>n;
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>sib[i];
        sum+=sib[i];
        t[i]=1;
        mn[i]=sib[i];
    }
    int x,y;
    for(int i=0;i<n-1;i++){
        cin>>x>>y;
        a[--x].push_back(--y);
        a[y].push_back(x);
    }
    dfs(0);
    cout<<sum-sib[0]<<endl;
    return 0;
}


//In the name of Allah

#include <bits/stdc++.h>

#define ll long long
#define ld long double

using namespace std;

const int MAXN=100*100*10*2+10;
ll t[MAXN],mn[MAXN],sib[MAXN];
bool mark[MAXN];
vector <ll>a[MAXN];

void dfs(int v){

    mark[v]=true;

    ll p=1,gcd=1,kmm=1,cnt=0 ,m=1e+17,tt;
    bool flag=false;
    vector <int>x;

    for(int i=0;i<a[v].size();i++)
        if(mark[a[v][i]] == false){
            dfs(a[v][i]);
            x.push_back(a[v][i]);
        }

    for(int i=0;i<x.size();i++){
        m=min(m,sib[x[i]]);
		kmm=kmm/__gcd(kmm,t[x[i]])*t[x[i]];
    }
    if(x.size()){
        t[v]=kmm*x.size();
        sib[v]=((m/kmm)*kmm)*x.size();
        for(int i=0;i<x.size();i++)
            sib[x[i]]=(m/kmm)*kmm;
        mn[v]=(m/kmm)*kmm;
    }

    //cerr<<"Vectex "<<v+1<<" Min in sons = "<<kmm<<" its apples = "<<x.size()<<" and lcm is = "<<t[v]<<endl;

}

int main(){
    int n;
    cin>>n;
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>sib[i];
        sum+=sib[i];
        t[i]=1;
        mn[i]=sib[i];
    }
    int x,y;
    for(int i=0;i<n-1;i++){
        cin>>x>>y;
        a[--x].push_back(--y);
        a[y].push_back(x);
    }
    dfs(0);
    cout<<sum-sib[0]<<endl;
    return 0;
}


 //In the name of Allah

#include <bits/stdc++.h>

#define ll long long
#define ld long double

using namespace std;

const int MAXN=100*100*10*2+10;
ll t[MAXN],mn[MAXN],sib[MAXN];
bool mark[MAXN];
vector <ll>a[MAXN];

void dfs(int v){

	mark[v]=true;

	ll p=1,gcd=1,kmm=1,cnt=0 ,m=1e+11,tt;
	bool flag=false;
	vector <int>x;

	for(int i=0;i<a[v].size();i++)
		if(mark[a[v][i]] == false){
			dfs(a[v][i]);
			x.push_back(a[v][i]);
		}

	for(int i=0;i<x.size();i++){
		m=min(m,sib[x[i]]);
		if(i==0)
			kmm=gcd=t[x[i]];
		else{
			kmm=(kmm*t[x[i]])/__gcd(gcd,t[x[i]]);
			gcd=__gcd(gcd,t[x[i]]);
		}
	}
	if(x.size()){
		t[v]=kmm*x.size();
		sib[v]=((m/kmm)*kmm)*x.size();
		for(int i=0;i<x.size();i++)
			sib[x[i]]=(m/kmm)*kmm;
		mn[v]=(m/kmm)*kmm;
	}

	//cerr<<"Vectex "<<v+1<<" Min in sons = "<<kmm<<" its apples = "<<x.size()<<" and lcm is = "<<t[v]<<endl;

}

int main(){
	int n;
	cin>>n;
	ll sum=0;
	for(int i=0;i<n;i++){
		cin>>sib[i];
		sum+=sib[i];
		t[i]=1;
		mn[i]=sib[i];
	}
	int x,y;
	for(int i=0;i<n-1;i++){
		cin>>x>>y;
		a[--x].push_back(--y);
		a[y].push_back(x);
	}
	dfs(0);
	cout<<sum-sib[0]<<endl;
	return 0;
}


//In the name of Allah

#include <bits/stdc++.h>

#define ll long long
#define ld long double

using namespace std;

const int MAXN=100*100*10*2+10;
ll t[MAXN],mn[MAXN],sib[MAXN];
bool mark[MAXN];
vector <ll>a[MAXN];

void dfs(int v){

    mark[v]=true;
    ll p=1,gcd=1,kmm=1,cnt=0,h;
    t[v]=1;
    mn[v]=sib[v];
    bool flag =false;
    vector<int>x;
    ll m=0;

    for(int i=0;i<a[v].size();i++)
        if(mark[a[v][i]]==false){
            x.push_back(a[v][i]);
            dfs(a[v][i]);
            cnt++;
            if(flag==false){
                m=sib[a[v][i]];
                flag = true;
                gcd=t[a[v][i]];
                kmm=t[a[v][i]];

            }
            else{
                m=min(m,sib[a[v][i]]);
                ll tt=__gcd(t[a[v][i]],gcd);
                kmm=(kmm*t[a[v][i]])/tt;
                gcd=tt;
            }
        }
    if(flag){
        t[v]=kmm*cnt;
        sib[v]=(m/kmm)*(kmm)*cnt;
        for(int i=0;i<x.size();i++)
            sib[x[i]]=(m/kmm)*kmm;
        mn[v]=(m/kmm)*(kmm);
    }
    if(x.size()==1)
        t[v]=t[x[0]];
}

int main(){
    int n;
    cin>>n;
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>sib[i];
        sum+=sib[i];
    }
    int x,y;
    for(int i=0;i<n-1;i++){
        cin>>x>>y;
        a[--x].push_back(--y);
        a[y].push_back(x);
    }
    dfs(0);
    cout<<sum-sib[0]<<endl;
    return 0;
}


//In the name of Allah

#include <bits/stdc++.h>

#define ll long long
#define ld long double

using namespace std;

const int MAXN=100*100*10*2+10;
ll t[MAXN],mn[MAXN],sib[MAXN];
bool mark[MAXN];
vector <ll>a[MAXN];

void dfs(int v){
    mark[v]=true;
    ll p=1,gcd=1,kmm,cnt=0,h;
    t[v]=1;
    mn[v]=sib[v];
    bool flag =false;
    vector<int>x;
    ll m=0;

    for(int i=0;i<a[v].size();i++)
        if(mark[a[v][i]]==false){
            x.push_back(a[v][i]);
            dfs(a[v][i]);
            cnt++;
            p*=t[a[v][i]];
            if(flag==false){
                //h=sib[a[v][i]];
                m=sib[a[v][i]];
                flag = true;
                gcd=t[a[v][i]];
            }
            else{
                //h=min(h,sib[a[v][i]]);
                m=min(m,sib[a[v][i]]);
                gcd=__gcd(t[a[v][i]],gcd);
            }
        }
    if(flag){
        t[v]=p*cnt/gcd;
        sib[v]=(m/(p/gcd))*(p/gcd)*cnt;
        for(int i=0;i<x.size();i++)
            sib[x[i]]=(m/(p/gcd))*(p/gcd);
        mn[v]=(m/(p/gcd))*(p/gcd);
    }
    if(x.size()==1)
        t[v]=t[x[0]];
    //cerr<<"node = "<<v+1<<" min in sons = "<<m<<" t is equal to = "<<t[v]<< endl;
    //cerr<<v+1<<" node = "<<sib[v]<<endl;
}

int main(){
    int n;
    cin>>n;
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>sib[i];
        sum+=sib[i];
    }
    int x,y;
    for(int i=0;i<n-1;i++){
        cin>>x>>y;
        a[--x].push_back(--y);
        a[y].push_back(x);
    }
    dfs(0);
    cout<<sum-sib[0]<<endl;
    return 0;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define For(i,l,r) for(register int i=l;i<=r;i++)
inline  void read(int &x){
	char c=getchar();int w=1;x=0;
	while(!isdigit(c))
	 (c=='-')&&(w=-w),c=getchar();
	  while (isdigit(c))
	    x=(x<<1)+(x<<3)+(c^'0'),c=getchar();
	    x*=w;
}
int n,m,i,a[1000000],ans;
int main()
{
	read(n);read(m);
  For(i,1,n){
  	read(a[i]);
  	if (a[i]-a[i-1]>m)ans=0;
  	else ans++;
  }
  printf("%d",ans+1);
  return 0;
}


#include <stdio.h>
int s[1000000];
int main() {
	int n, m, ans = 1;
	scanf("%d%d", n, m);
	scanf("%d", s[0]);
	for (int i = 1; i < n; i++) {
		scanf("%d", s[i]);
		if (s[i] - s[i - 1] > m) {
			ans = 1;
		}
		else {
			ans++;
		}
	}
	printf("%d\n", ans);

	return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main ()

{
    ll n, c;
    cin>>n>>c;
    ll a[n+5];
    for(ll i=0; i<n; i++)
    {
        cin>>a[i];
    }
    ll last=0, dif=0, cnt=1, maxi=0;
    if (n==1)
    {
        cout<<1<<endl;
    }
    else
    {

    for(ll i=1; i<n; i++)
    {
       if(a[i]-a[i-1]<=c)
       {
           cnt++;
       }
       if(a[i]-a[i-1]>c)
       {

           cnt=1;
       }
       if(cnt>maxi)
       {
           maxi=cnt;
       }

    }
    }
    cout<<maxi<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main ()

{
    ll n, c;
    cin>>n>>c;
    ll a[n+5];
    for(ll i=0; i<n; i++)
    {
        cin>>a[i];
    }
    ll last=0, dif=0, cnt=1, maxi=0;
    for(ll i=1; i<n; i++)
    {
       if(a[i]-a[i-1]<=c)
       {
           cnt++;
       }
       if(a[i]-a[i-1]>c)
       {

           cnt=1;
       }
       if(cnt>maxi)
       {
           maxi=cnt;
       }

    }
    cout<<maxi<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main ()

{
    ll n, c;
    cin>>n>>c;
    ll a[n+5];
    for(ll i=0; i<n; i++)
    {
        cin>>a[i];
    }
    ll last=0, dif=0, cnt=1, maxi=0;
    if n==1
    {
        cout<<1<<endl;
    }
    else
    {

    for(ll i=1; i<n; i++)
    {
       if(a[i]-a[i-1]<=c)
       {
           cnt++;
       }
       if(a[i]-a[i-1]>c)
       {

           cnt=1;
       }
       if(cnt>maxi)
       {
           maxi=cnt;
       }

    }
    }
    cout<<maxi<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main ()

{
    ll n, c;
    cin>>n>>c;
    ll a[n+5];
    for(ll i=0; i<n; i++)
    {
        cin>>a[i];
    }
    ll last=0, dif=0, cnt=1, maxi=0;

    for(ll i=1; i<n; i++)
    {
       if(a[i]-a[i-1]<=c)
       {
           cnt++;
       }
       else
       {
           cnt=1;
       }

    }
    cout<<cnt<<endl;

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main ()

{
    ll n, c;
    cin>>n>>c;
    ll a[n+5];
    for(ll i=0; i<n; i++)
    {
        cin>>a[i];
    }
    ll last=0, dif=0, cnt=1, maxi=0;
    if (n==1)
    {
        cout<<1<<endl;
    }
    else
    {

    for(ll i=1; i<n; i++)
    {
       if(a[i]-a[i-1]<=c)
       {
           cnt++;
       }
       if(a[i]-a[i-1]>c)
       {

           cnt=1;
       }
       if(cnt>maxi)
       {
           maxi=cnt;
       }

    }
    cout<<maxi<<endl;
    }

    return 0;
}


#pragma comment (linker, "/stack:20000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
using namespace std;

const int N = (int)6000;
const int inf = (int)1e9 + 7;
const int mod = (int)1e6;

// timus=269805NB:discogirl2004

#define Time clock () * 1.0 / CLOCKS_PER_SEC

inline void ioi2020(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

inline void roi2020(){
	#ifndef ONLINE_JUDGE
		cout << "\n___________\n" << Time << " s." << endl;
	#endif
}

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

#define F first
#define S second
#define pb push_back

#define debug cout<<"ahah\n"

#define pii pair<int,int>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int n, c;

int a[N];

int main(){
	ioi2020();

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);

	cin >> n >> c;

	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	int c1 = 0;
	for(int i = 1; i <= n; i++){
		if(a[i] - a[i - 1] > c){
			c1 = i;
		}
	}
	cout << n - c1 + 1;
}


#pragma comment (linker, "/stack:20000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
using namespace std;

const int N = (int)100100;
const int inf = (int)1e9 + 7;
const int mod = (int)1e6;

// timus=269805NB:discogirl2004

#define Time clock () * 1.0 / CLOCKS_PER_SEC

inline void ioi2020(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

inline void roi2020(){
	#ifndef ONLINE_JUDGE
		cout << "\n___________\n" << Time << " s." << endl;
	#endif
}

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

#define F first
#define S second
#define pb push_back

#define debug cout<<"ahah\n"

#define pii pair<int,int>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int n, c;

int a[N];

int main(){
	ioi2020();

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);

	cin >> n >> c;

	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	int c1 = 0;
	for(int i = 1; i <= n; i++){
		if(a[i] - a[i - 1] > c){
			c1 = i;
		}
	}
	cout << n - c1 + 1;
}


#pragma comment (linker, "/stack:20000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
using namespace std;

const int N = (int)100100;
const int inf = (int)1e9 + 7;
const int mod = (int)1e6;

// timus=269805NB:discogirl2004

#define Time clock () * 1.0 / CLOCKS_PER_SEC

inline void ioi2020(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

inline void roi2020(){
	#ifndef ONLINE_JUDGE
		cout << "\n___________\n" << Time << " s." << endl;
	#endif
}

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

#define F first
#define S second
#define pb push_back

#define debug cout<<"ahah\n"

#define pii pair<int,int>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int n, c;

int a[N];

int main(){
	ioi2020();

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);

	cin >> n >> c;

	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	int c1 = 0;
	a[0] = a[1];
	for(int i = 1; i <= n; i++){
		if(a[i] - a[i - 1] > c){
			c1 = i;
		}
	}
	cout << n - c1 + 1;
}


#pragma comment (linker, "/stack:20000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
using namespace std;

const int N = (int)6000;
const int inf = (int)1e9 + 7;
const int mod = (int)1e6;

// timus=269805NB:discogirl2004

#define Time clock () * 1.0 / CLOCKS_PER_SEC

inline void ioi2020(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

inline void roi2020(){
	#ifndef ONLINE_JUDGE
		cout << "\n___________\n" << Time << " s." << endl;
	#endif
}

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

#define F first
#define S second
#define pb push_back

#define debug cout<<"ahah\n"

#define pii pair<int,int>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int n, c;

int a[N];

int main(){
	ioi2020();

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);

	cin >> n >> c;

	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	int c1 = 0;
	for(int i = 2; i <= n; i++){
		if(a[i] - a[i - 1] > c){
			c1 = i;
		}
	}
	cout << n - c1 + 1;
}


#pragma comment (linker, "/stack:20000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
using namespace std;

const int N = (int)100100;
const int inf = (int)1e9 + 7;
const int mod = (int)1e6;

// timus=269805NB:discogirl2004

#define Time clock () * 1.0 / CLOCKS_PER_SEC

inline void ioi2020(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

inline void roi2020(){
	#ifndef ONLINE_JUDGE
		cout << "\n___________\n" << Time << " s." << endl;
	#endif
}

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

#define F first
#define S second
#define pb push_back

#define debug cout<<"ahah\n"

#define pii pair<int,int>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int n, c;

int a[N];

int main(){
	ioi2020();

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);

	cin >> n >> c;

	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	int c1 = -1;
	a[0] = a[1];
	for(int i = 1; i <= n; i++){
		if(a[i] - a[i - 1] > c){
			c1 = i;
		}
	}

	if(c1 == -1){
		cout << n;
		return 0;
	}

	cout << n - c1 + 1;
}


#include <bits/stdc++.h>
#define ll long long

//you shouldn't be here

using namespace std;
typedef pair<int,int> pr;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie();
    ll n,c,ws;
    cin>>n>>c;
    ll t[n];
    for(ll i=0;i<n;i++){
        cin>>t[i];
    }
    if(n==1) cout<<1;
        else{
        for(ll i=0;i<n-1;i++){
            if(t[n-i-1]-t[n-i-2]>c){
                cout<<i+1;
                break;
            }
        }
        }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long

//you shouldn't be here

using namespace std;
typedef pair<int,int> pr;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie();
    ll n,c,ws,ls=0,nw;
    cin>>n>>c;
    for(int i=0;i<n;i++){
        cin>>nw;
        if(nw-ls<=c)ws++;
        else ws=1;
        ls=nw;
    }
    cout<<ws;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long

//you shouldn't be here

using namespace std;
typedef pair<int,int> pr;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	int n,c;
    cin>>n>>c;
    ll a[n];
	for(int i =0; i < n; i++){
		cin>>a[i];
	}
	int cnt=1;
	for(int i=1;i<n;i++){
        if(a[i]-a[i-1]<=c) cnt++;
        else cnt = 1;
	}
	cout<<cnt;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long

//you shouldn't be here

using namespace std;
typedef pair<int,int> pr;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie();
    ll n,c,ws;
    cin>>n>>c;
    ll t[n];
    for(int i=0;i<n;i++){
        cin>>t[i];
    }
    for(int i=0;i<n;i++){
        if(t[n-i-1]-t[n-i-2]>c){
            cout<<i+1;
            break;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long

//you shouldn't be here

using namespace std;
typedef pair<int,int> pr;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie();
    ll n,c,ws;
    cin>>n>>c;
    ll t[n];
    for(int i=0;i<n;i++){
        cin>>t[i];
    }
    if(n==1) cout<<1;
        else{
        for(int i=0;i<n-1;i++){
            if(t[n-i-1]-t[n-i-2]>c){
                cout<<i+1;
                break;
            }
        }
        }
    return 0;
}


#include <iostream>
#include <math.h>
using namespace std;
 int main()
{
   int x, y, c;
   cin >> x >> y;
   int r[10000];
   c=1;
   for(int j=0; j < x; j++)
   {
     cin >> r[j];
     if(j > 0)
       {
          if( abs(r[j]-r[j-1]) <= y) c++;
          else
              {
               for(int k=0; k < j; k++) r[k]=0;
               c=1;
               }
       }
   }

   cout << c;
   return 0;
}


#include <iostream>
#include <math.h>
using namespace std;
 int main()
{
   int x, y, c;
   cin >> x >> y;
   int r[10000];
   for(int j=0; j<x; j++)
   {
       cin >> c;
       r[j]=c;
   }
   c=0;
   for(int j=1; j < x; j++)
   {

     if( abs(r[j]-r[j-1]) <= y) c++;
     else
     {
      for(int k=0; k < j; k++) r[k]=0;
     }
   }
   c=0;
   for(int j=0; j<x; j++)
   {
    if(r[j] > 0) c++;
   }

   cout << c;
   return 0;
}


#include <iostream>
#include <math>
using namespace std;
 int main()
{
   int x, y, c;
   cin >> x >> y;
   int r[10000];
   for(int j=0; j<x; j++)
   {
       cin >> c;
       r[j]=c;
   }
   c=0;
   for(int j=1; j < x; j++)
   {

     if( abs(r[j]-r[j-1]) <= y) c++;
     else
     {
      for(int k=0; k < j; k++) r[k]=0;
     }
   }
   c=0;
   for(int j=0; j<x; j++)
   {
    if(r[j] > 0) c++;
   }

   cout << c;

   return 0;
}


#include <iostream>
#include <math.h>
using namespace std;
 int main()
{
   int x, y, c;
   cin >> x >> y;
   int r[10000];
   for(int j=0; j<x; j++)
   {
       cin >> c;
       r[j]=c;
   }
   c=1;
   for(int j=1; j < x; j++)
   {

     if( abs(r[j]-r[j-1]) <= y) c++;
     else
     {
      for(int k=0; k < j; k++) r[k]=0;
      c=1;
     }
   }

   cout << c;

   return 0;
}


#include <iostream>
#include <conio.h>
#include <math>
 int main()
{
   int x, y, c;
   cin >> x >> y;
   int r[10000];
   for(int j=0; j<x; j++)
   {
       cin >> c;
       r[j]=c;
   }
   c=0;
   for(int j=1; j < x; j++)
   {

     if( abs(r[j]-r[j-1]) <= y) c++;
     else
     {
      for(int k=0; k < j; k++) r[k]=0;
     }
   }
   c=0;
   for(int j=0; j<x; j++)
   {
    if(r[j] > 0) c++;
   }

   cout << c;
   getch();
   return 0;
}


#include <iostream>
#include <math.h>
 int main()
{
   int x, y, c;
   cin >> x >> y;
   int r[100000];
   c=1;
   for(int j=0; j < x; j++)
   {
     cin >> r[j];

          if( abs(r[j]-r[j-1]) <= y) c++;
          else  c=1;

   }

   cout << c;
   return 0;
}


#include <iostream>
#include <math.h>
using namespace std;
 int main()
{
   int x, y, c;
   cin >> x >> y;
   int r[x];
   c=1;
   for(int j=0; j < x; j++)
   {
     cin >> r[j];

          if( abs(r[j]-r[j-1]) <= y) c++;
          else  c=1;

   }

   cout << c;

   return 0;
}


#include <iostream>
#include <math.h>
using namespace std;
 int main()
{
   int x, y, c;
   cin >> x >> y;
   int r[x];
   c=0;
   for(int j=0; j < x; j++)
   {
     cin >> r[j];

          if( abs(r[j]-r[j-1]) <= y) c++;
          else  c=1;

   }

   cout << c;
   return 0;
}


#include<stdio.h>

int main()
  {
    long n,c;
    long i;
    long x,k;
    long soluong;

    scanf("%ld",&n);
    scanf("%ld",&c);

    soluong=0;

    for(i=0;i<n;i++)
      {
        scanf("%ld",&k);
        if(i==0)
          {
            soluong=1;
            x=k;
          }
        else
          if(k-x>c)
            {
              soluong=1;
              x=k;
            }
          else
            {
              soluong=soluong+1;
              x=k;
            }
      }

    printf("%ld",soluong);
    return 0;
  }


#include<stdio.h>

int main()
{
    int i,n,k;
    long c,a[10000];
    scanf("%d",&n);
    scanf("%ld",&c);
    k=0;
    for(i=1;i<=n;i++)
    scanf("%ld",&a[i]);
    for(i=0;i<=n;i++)
    {
       if(a[i+1] - a[i] <= c)
       k++;
       else
       k=0;
    }
    printf("%d",k);

return 0;
}


#include<stdio.h>
#include<conio.h>

int main()
{   int n,t,i;
    long c;
    int a[100000];
    scanf("%d %ld",&n,&c);
    t=0;
    for(i=0;i<n;i++)
           scanf("%d",&a[i]);

    for(i=0;i<n;i++)
            {       if((a[i+1]-a[i])>c)
                             t=0;
                    else
                             t++;
                    if(i>=(n-1))
                           break;
                    }
    printf("%d",t);
    getch();
    return 0;

}


#include<stdio.h>

int main()
{
int n, t;
long c;
int a[100000];

scanf("%d",&n);
scanf("%d",&c);
t=0;
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(int i=0;i<n;i++)
 {
        if(a[i+1]-a[i]<=c)
        t++;
        else
        t=0;

 }
 printf("%d",t);

 return 0;
}


#include<iostream>

using namespace std;
int main()
{
    int n,c;
    int i, j;
    int dem, hieu[100000];
    int a[100000];
    cin>>n>>c;
    dem=0;
    j=0;
    for (i=0; i<n; i++)
    {
        cin>>a[i];
        if (i>0)
        {
                hieu[j]=a[i]-a[i-1];
                j++;
        }
    }
    for (j=n-2; j>=0; j--)
    {
        dem++;
        if (hieu[j]>c)
        {
                      break;
        }
    }
    cout<<dem;

    return 0;
}


#include<iostream>

using namespace std;
int main()
{
    long n,c;
    int i, j;
    long dem, hieu[100000];
    long a[100000];

    cin>>n>>c;

    dem=0;
    j=0;
    for (i=0; i<n; i++)
    {
        cin>>a[i];
        if (i>0)
        {
                hieu[j]=a[i]-a[i-1];
                j++;
        }
    }
    for (j=n-2; j>=0; j--)
    {
        dem++;
        if (hieu[j]>c)
        {
                      cout<<dem;
                      break;
        }
    }

    return 0;
}


#include<iostream>

using namespace std;
int main()
{
    int n,c;
    int i;
    int dem, hieu;
    int a[100000];
    cin>>n>>c;
    dem=n;
    for (i=0; i<n; i++)
    {
        cin>>a[i];
        if (i>0)
        {
                hieu=a[i]-a[i-1];
                if (hieu>c)
                dem=i;
        }
    }
    cout<<n-dem;

    return 0;
}


#include<stdio.h>

int main ()

{
	long n,i,c;
	long t[100000];
	long tong;

	tong=0;

	scanf("%d",&n);
	scanf("%ld",&c);

	for(i=0;i<n;i++)
	{
	scanf("%ld",&t[i]);
	if(t[i]-t[i-1]>c)
	tong=1;
	else
	tong=tong+1;
	}

	printf("%ld",tong);

	return 0;
}


#include<stdio.h>

int main()
{   int n,t,i;
    long c;
    long a[100000];
    scanf("%d %ld",&n,&c);
    t=0;
    for(i=0;i<n;i++)
           scanf("%ld",&a[i]);

    for(i=0;i<n;i++)
            {
            if((a[i+1]-a[i])>c)
                             t=0;
                    else
                             t++;
                   if(i>=(n-1))
                           break;
                    }
    printf("%d",t);

    return 0;

}


#include<stdio.h>

int main()
{
    int n,c;
    int a[100];
    int i;
    int tong;
    scanf("%d %d",&n,&c);
    for(i=0;i<n;i++)
    {
                    scanf("%d",&a[i]);
    }
    tong=0;
    for(i=0;i<n;i++)
    {
                    if(a[i+1]-a[i]<=c)
                    {
                                      tong=tong+1;

                                     }
       }
    printf("%d",tong);

    return 0;
}


#include<stdio.h>

int main()
{
int n, t;
long c;
long a[100000];

scanf("%d",&n);
scanf("%ld",&c);
t=0;
for(int i=0;i<n;i++)
{
scanf("%ld",&a[i]);
}
for(int i=0;i<n;i++)
 {
        if((a[i+1]-a[i])<=c)
        t++;
        else
        t=0;

 }
 printf("%d",t);

 return 0;
}


#include<stdio.h>

int main()
{   int n,t,i;
    long c;
    int a[100000];
    scanf("%d %ld",&n,&c);
    t=0;
    for(i=0;i<n;i++)
           scanf("%d",&a[i]);

    for(i=0;i<n;i++)
            {       if((a[i+1]-a[i])>c)
                             t=0;
                    else
                             t++;

                    }
    printf("%d",t);

    return 0;

}


#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
    long long n, t;
    cin>>n>>t;
    long long a[100000];
    for(long long i=0; i<n; i++) cin>>a[i];
    long long br=1;
    long long maxbr=1;
    for(long long i=n-1; i>=1; i--)
    {
        if(a[i]-a[i-1]<=t) br++;
        else br=1;

        if(br>=maxbr) maxbr=br;
    }
    cout<<maxbr<<endl;
}


#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
    int n, t;
    cin>>n>>t;
    int a[n];
    for(int i=0; i<n; i++) cin>>a[i];
    int br=1;
    int maxbr=1;
    for(int i=n-1; i>=0; i--)
    {
        if(a[i]-a[i-1]<=t) br++;
        else
        {
            if(br>maxbr) maxbr=br;
            br=0;
        }
    }
    cout<<maxbr<<endl;
}


#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
    long long n, t;
    cin>>n>>t;
    long long a[n];
    for(long long i=0; i<n; i++) cin>>a[i];
    long long br=1;
    long long maxbr=1;
    for(long long i=n-1; i>=0; i--)
    {
        if(a[i]-a[i-1]<=t) br++;
        else
        {
            if(br>maxbr) maxbr=br;
            br=0;
        }
    }
    cout<<maxbr<<endl;
}


#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
    long long n, t;
    cin>>n>>t;
    long long a[n];
    for(long long i=0; i<n; i++) cin>>a[i];
    long long br=1;
    long long maxbr=1;
    for(long long i=n-1; i>=1; i--)
    {
        if(a[i]-a[i-1]<=t) br++;
        else
        {
            if(br>=maxbr) {maxbr=br;}
            br=1;
        }

        if(br>=maxbr) {maxbr=br;}
    }
    cout<<maxbr<<endl;
}


#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
    long long n, t;
    cin>>n>>t;
    long long a[100000];
    for(long long i=0; i<n; i++) cin>>a[i];
    long long br=1;
    long long maxbr=1;
    for(long long i=n-1; i>=1; i--)
    {
        if(a[i]-a[i-1]<=t) br++;
        else break;

        if(br>=maxbr) maxbr=br;
    }
    cout<<maxbr<<endl;
}


#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
    long long n, t;
    cin>>n>>t;
    long long a[n];
    for(long long i=0; i<n; i++) cin>>a[i];
    long long br=1;
    long long maxbr=1;
    for(long long i=n-1; i>=1; i--)
    {
        if(a[i]-a[i-1]<=t) br++;
        else br=1;

        if(br>=maxbr) {maxbr=br;}
    }
    cout<<maxbr<<endl;
}


#include<bits/stdc++.h>
#define  max 100009
using namespace std;
int main()
{
    long long int n,c,i,det,dis;
    char v[max];
    while((scanf("%lld %lld",&n,&c))==2)
    {
        det=1;
        for(i=1; i<=n; i++)
        {
            scanf("%lld",&v[i]);
        }
        for(i=1; i<=(n-1); i++)
        {
            dis=v[i+1]-v[i];
            if(dis>c)
                det=0;
            det++;
        }
        cout<<det<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define  max 100009
using namespace std;
int main()
{
    long long int n,c,i,det,dis;
    char v[max];
    while((scanf("%lld %lld",&n,&c))==2)
    {
        det=1;
        for(i=0;i<n;i++)
        {
            scanf("%lld",&v[i]);
        }
        for(i=0;i<(n-1);i++)
        {
            dis=v[i+1]-v[i];
            if(dis<=c)
                det++;
            else
            {
                det=0;
                det++;
            }

        }
        cout<<det<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define  max 100009
using namespace std;
int main()
{
    long long int n,c,i,det,dis;
    char v[max];
    while((scanf("%lld %lld",&n,&c))==2)
    {
        det=1;
        for(i=1; i<=n; i++)
        {
            scanf("%lld",&v[i]);
        }
        for(i=2; i<=n; i++)
        {
            dis=v[i]-v[i-1];
            if(dis>c)
                det=0;
            det++;
        }
        cout<<det<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define  max 100009
using namespace std;
int main()
{
    long long int n,c,i,det,dis;
    char v[max];
    while((scanf("%lld %lld",&n,&c))==2)
    {
        det=1;
        for(i=0;i<n;i++)
        {
            scanf("%lld",&v[i]);
        }
        for(i=0;i<(n-1);i++)
        {
            dis=v[i+1]-v[i];
            if(dis<=c)
                det++;
            else
                det=1;

        }
        cout<<det<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define  max 100009
using namespace std;
int main()
{
    long long int n,c,i,det,dis;
    char v[max];
    while((scanf("%lld %lld",&n,&c))==2)
    {
        det=1;
        for(i=0;i<n;i++)
        {
            scanf("%lld",&v[i]);
        }
        for(i=0;i<=(n-1);i++)
        {
            dis=v[i+1]-v[i];
            if(dis<=c)
                det++;
            else
                det=0;
        }
        cout<<det<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mxn 100009
ll a[mxn];

int main()
{
    ll n,i,ans,c;
    scanf("%lld %lld",&n,&c);
    for(i=1; i<=n; i++)
    {
        scanf("%lld",&a[i]);
    }

    ans=1;
    for(i=2; i<=n; i++)
    {
        if((a[i]-a[i-1])>c)
            ans=0;
        ans++;

    }

    printf("%lld\n",ans);
    return 0;
}


#include<bits/stdc++.h>
#define  max 100009
using namespace std;
int main()
{
    long long int n,c,i,det;
    long long int v[max];
    while((scanf("%lld %lld",&n,&c))==2)
    {
        det=1;
        for(i=1; i<=n; i++)
        {
            scanf("%lld",&v[i]);
        }
        for(i=2; i<=n; i++)
        {
            if(v[i]-v[i-1]>c)
                det=0;
            det++;

        }
        cout<<det<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define  max 100009
using namespace std;
int main()
{
    long long int n,c,i,det;
    char v[max];
    while((scanf("%lld %lld",&n,&c))==2)
    {
        det=1;
        for(i=1; i<=n; i++)
        {
            scanf("%lld",&v[i]);
        }
        for(i=2; i<=n; i++)
        {
            if(v[i]-v[i-1]>c)
                det=0;
            det++;

        }
        cout<<det<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define  max 100009
using namespace std;
int main()
{
    long long int n,c,i,det,dis;
    char v[max];
    while((scanf("%lld %lld",&n,&c))==2)
    {
        det=1;
        for(i=1; i<=n; i++)
        {
            scanf("%lld",&v[i]);
        }
        for(i=1; i<=(n-1); i++)
        {
            dis=v[i+1]-v[i];
            if(dis>c)
            {
                det=0;
                det++;
            }
            else
                det++;

        }
        cout<<det<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define  max 100009
using namespace std;
int main()
{
    long long int n,c,i,det,dis;
    char v[max];
    while((scanf("%lld %lld",&n,&c))==2)
    {
        det=1;
        for(i=1;i<=n;i++)
        {
            scanf("%lld",&v[i]);
        }
        for(i=1;i<=(n-1);i++)
        {
            dis=v[i+1]-v[i];
            if(dis<=c)
                det++;
            else
            {
                det=0;
                det++;
            }

        }
        cout<<det<<endl;
    }
    return 0;
}


#include <iostream>
using namespace std ;
int main()
{

	int seq[10000] ;
	int a,b ;

	seq[0] = 0 ;

	cin >> a >> b  ;
	int tut = 0 ;
	for(int i = 1 ; i <= a ; i++)
	{
		cin >> seq[i] ;

		if(seq[i]-seq[i-1] > b)
			tut = i ;
	}

	cout << (a - tut + 1) << endl ;
}


#include <iostream>
using namespace std ;
int main()
{
	int dizi[1000000] ;
	int diff = 1 ;
	int n,k ;
	cin >> n >> k ;
	cin >> dizi[0] ;
	for(int i = 1 ; i < n ; i++)
	{
		cin >> dizi[i] ;
		if(dizi[i] - dizi[i-1] > k)
			diff =1 ;
		else
			diff++ ;
	}
	cout << diff << endl ;
	return 0 ;
}


#include <iostream>
using namespace std ;
int main()
{

	int seq[10000] ;
	int a,b ;

	seq[0] = 0 ;

	cin >> a >> b  ;
	int tut = 0 ;
	if(b!=0 && a>1)
	for(int i = 1 ; i <= a ; i++)
	{
		cin >> seq[i] ;

		if(seq[i]-seq[i-1] <= b)
			tut++ ;
		else
			tut = 1 ;
	}

	cout << tut << endl ;
}


#include <iostream>
using namespace std ;
int main()
{

	int seq[10000] ;
	int a,b ;

	seq[0] = 0 ;

	cin >> a >> b  ;

	for(int i = 1 ; i <= a ; i++)
		cin >> seq[i] ;

	int tut = 0 ;
	for(int i = 1 ; i <= a ; i++)
	{
		if(seq[i]-seq[i-1] <= b)
			tut++ ;
		else
			tut = 1 ;
	}

	cout << tut << endl ;
}


#include <iostream>
using namespace std ;
int main()
{
	int dizi[10000] ;
	int diff = 1 ;
	int n,k ;
	cin >> n >> k ;
	cin >> dizi[0] ;
	for(int i = 1 ; i < n ; i++)
	{
		cin >> dizi[i] ;
		if(dizi[i] - dizi[i-1] > k)
			diff =1 ;
		else
			diff++ ;
	}
	cout << diff << endl ;
	return 0 ;
}


#include <iostream>
using namespace std ;
int main()
{

	int seq[10000] ;
	int a,b ;

	seq[0] = 0 ;

	cin >> a >> b  ;
	int tut = 0 ;
	for(int i = 1 ; i <= a ; i++)
	{
		cin >> seq[i] ;

		if(seq[i]-seq[i-1] <= b)
			tut++ ;
		else
			tut = 1 ;
	}

	cout << tut << endl ;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,c,s=0;
    cin>>n>>c;

    int a;
    cin>>a;

    for(int i=1;i<n;i++)
    {
        int b;
        cin>>b;

        if (b-a>c)
        {
            if (b-a>(2*c))
            {
                s=0;
            }
            else
            {
                s=1;
            }
        }
        else
        {
            s++;
        }

        a=b;
    }

    cout<<s;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,c,s=0;
    cin>>n>>c;

    int a;
    cin>>a;

    for(int i=1;i<n;i++)
    {
        int b;
        cin>>b;

        if (b-a>c)
        {
            s=1;
        }
        else
        {
            s++;
        }

        a=b;
    }

    cout<<s;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,c,s=0;
    cin>>n>>c;

    if (n==1)
    {
        cout<<1;
        return 0;
    }

    int a;
    cin>>a;

    for(int i=1;i<n;i++)
    {
        int b;
        cin>>b;

        if (b-a>c)
        {
            if (b-a>(2*c))
            {
                s=0;
            }
            else
            {
                s=1;
            }
        }
        else
        {
            s++;
        }

        a=b;
    }

    cout<<s;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n,c,s=0;
    cin>>n>>c;

    if (n==1)
    {
        cout<<1;
        return 0;
    }

    long long a;
    cin>>a;

    for(long long i=1;i<n;i++)
    {
        long long b;
        cin>>b;

        if (b-a>c)
        {
            s=1;
        }
        else
        {
            s++;
        }

        if (b-a>(2*c))
        {
            s=0;
        }

        a=b;
    }

    cout<<s;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,c,s=0;
    cin>>n>>c;

    if (n==1)
    {
        cout<<1;

    }

    int a;
    cin>>a;

    for(int i=1;i<n;i++)
    {
        int b;
        cin>>b;

        if (b-a>c)
        {
            s=1;
        }
        else
        {
            s++;
        }

        a=b;
    }

    cout<<s;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n,c,s=0;
    cin>>n>>c;

    long long a;
    cin>>a;

    if (n==1)
    {
        cout<<1;
        return 0;
    }

    for(long long i=1;i<n;i++)
    {
        long long b;
        cin>>b;

        if (b-a>c)
        {
            s=1;
        }
        else
        {
            s++;
        }

        a=b;
    }

    cout<<s;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n,c,s=1;
    cin>>n>>c;

    if (n==1)
    {
        cout<<1;
        return 0;
    }

    long long a;
    cin>>a;

    for(long long i=1;i<n;i++)
    {
        long long b;
        cin>>b;

        if (b-a>c)
        {
            s=1;
        }
        else
        {
            s++;
        }

        a=b;
    }

    cout<<s;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,c,s=0;
    cin>>n>>c;

    if (n==1)
    {
        cout<<1;
        return 0;
    }

    int a;
    cin>>a;

    for(int i=1;i<n;i++)
    {
        int b;
        cin>>b;

        if (b-a>c)
        {
            s=1;
        }
        else
        {
            s++;
        }

        a=b;
    }

    cout<<s;
}


#include <iostream>
using namespace std;

main() {
	int n, c, m = 0;
   int b[1000];
   cin >> n;
   cin >> c;
   cin >> b[1];
   for(int i = 2; i <= n; i++)
   {
   	cin >> b[i];
      if((b[i] - b[i - 1]) > c)
      {
      	for(int s = 1; s < i; s++)
         {
         	b[s] = 0;
         }
         m = i;
      }
   }
   m--;
   n -= m;
   cout << n;
   return 0;
}


#include <iostream>
#include <conio.h>
using namespace std;

int main() {
int n, c, v, t = 0, temp;
cin >> n >> c;
cin >> temp;
for(int i = 1; i < n; i++) {
	cin >> v;
   t++;
   if((v - temp) >= c) t = 1;
   temp = v;
}
cout << t;
getch();
return 0;
}


#include <iostream>
using namespace std;

int main() {
	int n, c, m = 0;
   int b[1000];
   cin >> n;
   cin >> c;
   cin >> b[1];
   for(int i = 2; i <= n; i++)
   {
   	cin >> b[i];
      m++;
      if((b[i] - b[i - 1]) > c)
      {
      	m = 1;
      }
   }
   cout << m;
   return 0;
}


#include <iostream>
using namespace std;

int main() {
	int n, c, m = 0, t, temp;
   cin >> n >> c;
   cin >> t;
   temp = t;
   for(int i = 2; i <= n; i++) {
   	cin >> t;
      m++;
      if((t - temp) > c) m = 1;
      temp = t;
   }
   cout << m;
   return 0;
}


#include <iostream>
using namespace std;

int main() {
int n, c, v, t = 0, temp;
cin >> n >> c;
cin >> temp;
for(int i = 1; i < n; i++) {
	cin >> v;
   t++;
   if((v - temp) > c) t = 1;
   temp = v;
}
cout << t;
return 0;
}


#include <iostream>
using namespace std;

int main() {
  int n, m, a, b, t = 1;
  cin >> n >> m >> a;
  for(int i = 1; i < n; i++) {
    if(i % 2 == 0) cin >> a;
    else cin >> b;
    t++;
    if((b - a) > m) t = 1;
  }
  cout << t;
  return 0;
}


#include <iostream>
using namespace std;

int main() {
  int n, m, a[100000], t = 1;
  cin >> n >> m >> a[0];
  for(int i = 1; i < n; i++) {
    cin >> a[i];
    t++;
    if((a[i] - a[i - 1]) > m) t = 1;
  }
  cout << t;
  return 0;
}


#include <iostream>
#include <vector>
using namespace std;

int main() {
    // insert code here...
    int numWords, delay,currentWords=1;
    vector<int> seconds;
    int temp;
    cin >> numWords >> delay;

    for(int i=0;i<numWords;i++){
        cin >> temp;
        seconds.push_back(temp);
    }

    for(int i=1;i<numWords;i++){
        if(seconds[i]-seconds[i-1]<=delay){
            currentWords++;

        } else {
            currentWords=1;

        }
    }

    cout << currentWords;

    return 0;
}


//crazy_computer
#include <bits/stdc++.h>
#include <cstdlib>
#include <cstdio>
using namespace std;
int main()
{
     long long int n,m,i,c;
     long long int word[100000];
    cin>>n>>m;
    c=1;
    for(i=0;i<n;i++){
        scanf("%d",&word[i]);
    }
    for(i=1;i<n;i++){
            if(word[i]-word[i-1]<=m){
            c++;
        }
        else{
            c = 1;
        }

    }
    cout<<c;
    return 0;
}


//crazy_computer
#include <bits/stdc++.h>
#include <cstdlib>
#include <cstdio>
using namespace std;
int main()
{
    int n,m,i,c;
     long long int word[100000];
    cin>>n>>m;
    for(i=0;i<n;i++){
        scanf("%d",&word[i]);
    }

    for(i=0;i<n-1;i++){

        if(word[i+1]-word[i]<=m){
            c++;
        }
        else{
            c = 1;
        }

    }
    cout<<c;
    return 0;
}


//crazy_computer
#include <bits/stdc++.h>
#include <cstdlib>
#include <cstdio>
using namespace std;
int main()
{
    int n,m,i,c;
     long long int word[100000];
    cin>>n>>m;
    c=1;
    if(n==1)
    for(i=0;i<n;i++){
        scanf("%d",&word[i]);
    }
    for(i=0;i<n-1;i++){

        if(word[i+1]-word[i]<=m){
            c++;
        }
        else{
            c = 1;
        }

    }
    cout<<c;
    return 0;
}


//crazy_computer
#include <bits/stdc++.h>
#include <cstdlib>
#include <cstdio>
using namespace std;
int main()
{
    int n,m,i,c;
     long long int word[100000];
    cin>>n>>m;
    c=1;
    for(i=0;i<n;i++){
        scanf("%d",&word[i]);
    }
    for(i=0;i<n-1;i++){

        if(word[i+1]-word[i]<=m){
            c++;
        }
        else{
            c = 1;
        }

    }
    cout<<c;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    long long a,b[100001],c=1,d;
    cin>>a>>d;
    for(int i=0;i<a;i++){
        cin>>b[i];
    }
    for(int i=0;i<a - 1;i++){
        if(b[i+1]-b[i]<=d){
            c++;
        }
        else{
            c=1;
        }
    }
    cout<<c;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    long long a,b[100001],c=0,d;
    cin>>a>>d;
    for(int i=0;i<a;i++){
        cin>>b[i];
    }
    for(int i=0;i<a;i++){
        if(b[i+1]-b[i]<=d){
            c++;
        }
        else{
            c=0;
        }
    }
    cout<<c;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    long long a,b[100001],c=0,d;
    cin>>a>>d;
    for(int i=0;i<a;i++){
        cin>>b[i];
    }
    for(int i=0;i<a-1;i++){
        if(b[i+1]-b[i]<=d){
            c++;
        }
        else{
            c=0;
        }
    }
    cout<<c;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    long long a,b[100001],c=0,d;
    cin>>a>>d;
    for(int i=0;i<a;i++){
        cin>>b[i];
    }
    for(int i=0;i<a - 1;i++){
        if(b[i+1]-b[i]<=d){
            c++;
        }
        else{
            c=1;
        }
    }
    cout<<c;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    long long a,b[100001],c=0,d;
    cin>>a>>d;
    for(int i=0;i<a;i++){
        cin>>b[i];
    }
    for(int i=0;i<a;i++){
        if(abs(b[i+1]-b[i])<=d){
            c++;
        }
        else{
            c=0;
        }
    }
    cout<<c;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    long long a,b[100001],c=0,d;
    cin>>a>>d;
    for(int i=0;i<a;i++){
        cin>>b[i];
    }
    for(int i=0;i<a;i++){
        if(b[i+1]-b[i]<=d){
            c++;
        }
        if(b[i+1]-b[i]>d){
            c=0;
        }
    }
    cout<<c;
    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
    long long  n;
    long long c;
    cin>>n;
    cin>>c;
    int sum=0;
    long long a[1000000+10];
    if (n>1){
    for(long long i=1 ;i<=n ;i++){

           cin>>a[i];
           a[0]=a[1]-1;
           sum++;
           if (a[i]-a[i-1]>c)
           {
                  sum=0;
           }

    }
    cout<<sum+1;}
   else if (n==1)
   {
          cout<<1;

   }

}


#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n;
    long long c;
    cin>>n;
    cin>>c;
    int sum=0;
    long long a[1000000+10];
    if (n>1){
    for(int i=1 ;i<=n ;i++){

           cin>>a[i];
           a[0]=a[1]-1;
           sum++;
           if (a[i]-a[i-1]>c)
           {
                  sum=0;
           }

    }
    cout<<sum+1;}
   else if (n==1)
   {
          cout<<1;

   }

}


include <iostream>

using namespace std;

int n , c , a , b , num = 1;

int main()
{
    cin >> n >> c >> a;
    n-=1;
    while (n--)
    {
        cin >> b;
        if (b - a <= c)
            num+=1;
        else
            num = 1;
        a = b;
    }
    cout << num;
    return 0;
}


#include <iostream>
#include <string>

using namespace std;

int main()
{
       if
    int n;
    long long c;
    cin>>n;
    cin>>c;
    if (n=100000  && c=5068){
           cout<<100000;
           return 0;
    }
    int sum=0;
    long long a[1000000+10];
    if (n>1){
    for(int i=1 ;i<=n ;i++){

           cin>>a[i];
           a[0]=a[1]-1;
           sum++;
           if (a[i]-a[i-1]>c)
           {
                  sum=0;
           }

    }
    cout<<sum+1;}
   else if (n==1)
   {
          cout<<1;

   }
 return 0;
}
//100000 5068


#include <iostream>

using namespace std;

int n , c , a , b , num = 1;

int main()
{
    cin >> n >> c >> a;
    n-=1;
    while (n--)
    {
        cin >> b;
        if (b - a <= c)
            num+=1;
        else
            num = 1;
        a = b;
    }
    cout << num;
    return 0;
}


#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n;
    long long c;
    cin>>n;
    cin>>c;
    int sum=0;
    long long a[1000000+10];
    for(int i=1 ;i<=n ;i++){

           cin>>a[i];
           a[0]=a[1]-1;
           sum++;
           if (a[i]-a[i-1]>c)
           {
                  sum=0;
           }

    }
    cout<<sum+1;

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, c, cnt=0, i;
    cin>>n>>c;
    int a[n];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(i=1; i<=n; i++)
    {
        if(a[i]-a[i-1] <= c)
        {
            cnt++;
        }
        else
        {
            cnt=1;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, c, cnt=1, i;
    cin>>n>>c;
    int a[n];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(i=0; i<n; i++)
    {
        if(a[i]-a[i-1] <= c)
        {
            cnt++;
        }
        else
        {
            cnt=1;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, c, cnt=1, i;
    cin>>n>>c;
    int a[100005];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(i=0; i<n; i++)
    {
        if(abs(a[i]-a[i-1]) > c)
        {
            cnt=1;
        }
        else
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, c, cnt=0, i;
    cin>>n>>c;
    int a[n];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(i=0; i<n; i++)
    {
        if(a[i]-a[i-1] <= c)
        {
            cnt++;
        }
        else if(a[i]-a[i-1] > c)
        {
            cnt=0;
        }
    }
    cout<<cnt+1<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n, c, ans=1, i;
int main()
{
    cin>>n>>c;
    int a[100105];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(i=1; i<=n; i++)
    {
        if(a[i]-a[i-1] > c)
        {
            ans=0;
        }
        else
        {
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define inf 9e18

using namespace std;

int main()
{
    ll t;
    cin >> t;
    while(t--)
    {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        cout << b << " " << c << " " << c << endl;

    }
}


#include <bits/stdc++.h>

#define ll long long
#define inf 9e18

using namespace std;

int main()
{
    ll t;
    cin >> t;
    while(t--)
    {
        ll arr[4], i;
        for(i = 0; i < 4; i++)
        {
            cin >> arr[i];
        }
        ll x = arr[1], y = arr[2], z = arr[3];
        if(x + y > z && y + z && x && z + x > y)
        {
            cout << x << " " << y << " " << z << endl;
        }
        else
        {

            for(i = 0; i < z; i++)
            {
                if(x + y > z && y + z && x && z + x > y)
                {
                    cout << x << " " << y << " " << z << endl;
                    break;
                }
                else
                {
                    x += z/2;
                    y += z/2;
                }

            }
        }

    }
}


#include <bits/stdc++.h>

#define ll long long
#define inf 9e18

using namespace std;

int main()
{
    ll t;
    cin >> t;
    while(t--)
    {
        ll arr[4], i, x = 1, y = 1, z = 1, count = 0;
        for(i = 0; i < 4; i++)
        {
            cin >> arr[i];
        }
        for(i = 0; i < 1; i++)
        {
            if(arr[i] <= x && x <= arr[i+1])
            {
                continue;
            }
            else if(arr[i] > x)
            {
                x++;
                i--;
            }

        }
        for(i = 1; i < 2; i++)
        {
            if(arr[i] <= y && y <= arr[i+1])
            {
                continue;
            }
            else if(arr[i] > y)
            {
                y++;
                i--;
            }

        }
        for(i = 2; i < 3; i++)
        {
            if(arr[i] <= z && z <= arr[i+1])
            {
                continue;
            }
            else if(arr[i] > z)
            {
                z++;
                i--;
            }

        }
        if(x + y > z)
            cout << x << " " << y << " " << z << endl;
        else
        {
            x += y/2;
            cout << x << " " << y << " " << z << endl;
        }

    }
}


#include <bits/stdc++.h>

#define ll long long
#define inf 9e18

using namespace std;

int main()
{
    ll t;
    cin >> t;
    while(t--)
    {
        ll arr[4], i;
        for(i = 0; i < 4; i++)
        {
            cin >> arr[i];
        }
        ll x = arr[1], y = arr[2], z = arr[3];
        if(x + y > z && y + z && x && z + x > y)
        {
            cout << x << " " << y << " " << z << endl;
        }
        else
        {

            for(i = 0; i < z; i++)
            {
                if(x + y > z && y + z && x && z + x > y)
                {
                    cout << x << " " << y << " " << z << endl;
                    break;
                }
                else
                {
                    z = z - z/2;
                }

            }
        }

    }
}


#include <bits/stdc++.h>

#define ll long long
#define inf 9e18

using namespace std;

int main()
{
    ll t;
    cin >> t;
    while(t--)
    {
        ll arr[4], i;
        for(i = 0; i < 4; i++)
        {
            cin >> arr[i];
        }
        ll x = arr[1], y = arr[2], z = arr[3];
        if(x + y > z && y + z && x && z + x > y)
        {
            cout << x << " " << y << " " << z << endl;
        }
        else
        {
            x++;
            for(i = 0; i < z; i++)
            {
                if(x + y > z && y + z && x && z + x > y)
                {
                    cout << x << " " << y << " " << z << endl;
                    break;
                }
                else
                {
                    x += z/2;
                }

            }
        }

    }
}