#include <bits/stdc++.h>             /*Fuck ratings Feel the magic in the code...*/
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
// template<typename T>
// using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*   in log(n) time...
    find_by_order() - Returns an iterator to the k-th largest element (counting from zero)
    order_of_key()  - The number of items in a set that are strictly smaller than our item
    // Rest same as set
*/
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod 1000000007
#define inf 2e18
#define minf -2e18
#define PI 3.141592653589793238462
#define ll long long
#define all(x) x.begin(), x.end()
#define min3(a, b, c) min(min(a, b), c)
#define max3(a, b, c) max(max(a, b), c)
#define ff first
#define ss second
#define pb push_back
#define ppb pop_back
#define sz(v) (int)v.size()
#define nline "\n"

ll powr(ll a, ll b, ll p) { if(b == 0) return 1; else if(b == 1) return a; else if(!(b & 1)) return powr((a * a) % p, b / 2, p); else return (a * powr(a, b - 1, p)) % p; }
ll gcd(ll a, ll b){ if(b == 0) return a; else return gcd(b, a % b); }
ll lcm(ll a, ll b){ return a * b / gcd(a, b); }
void extendgcd(ll a, ll b, ll *v) {if (b == 0) {v[0] = 1; v[1] = 0; v[2] = a; return ;} extendgcd(b, a % b, v); ll x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;} //pass an arry of size1 3
ll mminv(ll a, ll b) {ll arr[3]; extendgcd(a, b, arr); return arr[0]; } //for non prime b
ll mod_inv(ll a, ll p){ return powr(a,p-2,p); } /*For prime p  "Fermet lill theorem"*/
ll mod_add(ll a, ll b, ll m) { a = a % m; b = b % m; return ((a + b) % m + m) % m; }
ll mod_mul(ll a, ll b, ll m) { a = a % m; b = b % m; return ((a * b) % m + m) % m; }
ll mod_sub(ll a, ll b, ll m) { a = a % m; b = b % m; return ((a - b) % m + m) % m; }
ll mod_div(ll a, ll b, ll m) { a = a % m; b = b % m; return (mod_mul(a, mod_inv(b, m), m) + m) % m; } /*For prime p*/
// void swap(int &a, int &b) { int temp = a; a = b; b = temp; }
ll spf(ll n) { for(int i = 2; i * i <= n; i++) { if(n % i == 0) return i; } return n; }/* spf in sqrt(n) time... */
vector<ll> fact_modp(ll n, ll p) { vector<ll> fact(n + 1); fact[0] = 1; for(int i = 1; i <= n; i++){ fact[i] = (i * fact[i - 1]) % p; } return fact; }
/*For prime p "Fermet lill theorem..."*/
ll nCr_modp(ll n, ll r, ll p, vector<ll> fact) {  if(n < r) return 0; if(r == 0) return 1; else { return ((fact[n] * mod_inv(fact[r], p)) % p * mod_inv(fact[n - r], p)) % p; } }


vector<ll> prime_sieve(ll n) { /*Returns vector of prime <= n  in nloglogn time*/
    vector<ll> t;
    vector<bool> a(n + 1, true);
    a[0] = a[1] = false;
    for(int i = 2; i * i <= n; i++) {
        if(a[i]) {
            for(int j = i * i; j <= n; j += i)
            a[j] = false;
        }
    }
    for(int i = 0; i <= n; i++) {
        if(a[i])
        t.push_back(i);
    }
    return t;
}
vector<ll> spf_sieve(ll n) { /*Returns vector of spf[n] in nloglogn time*/
    vector<ll> a(n + 1, -1);
    for(int i = 2; i * i <= n; i++) {
        if(a[i] == -1) {
            a[i] = i;
            for(int j =i * i; j <= n; j += i) { if(a[j] == -1) a[j] = i;}
        }
    }
    for(int i = 2; i <= n; i++) { if(a[i] == -1) a[i] = i;}
    return a;
}
     /* --------------------------------------Template ends, Dee codes---------------------------------------*/

int main()
{
    fastio();

    int tests = 1;
    // cin >> tests;                  
    while(tests--)
    {
    	int n;
    	cin >> n;
    	vector<int> a(n);
    	ll res = 0;
    	map<int, ll> mp;
    	for(int i = 0; i < n; i++) {
    		cin >> a[i];
    		int r1 = (200 - (a[i] % 200));
    		if(r1 != 200) {
    			res += mp[200 - r1];
    		}
    		mp[a[i] % 200]++;
    	}
    	res += ((mp[0] * (mp[0] - 1)) / 2);
    cout << res << nline;

    }
    return 0;
}

#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#include <stdlib.h>
#include <fstream>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))
#define sq5(x) ((x) * (x) * (x) * (x) * (x))
#define N 400005

ll t[N * 4];

void push(int v) {
	if (t[v]) {
		t[v * 2] += t[v];
		t[v * 2 + 1] += t[v];
		t[v] = 0;
	}
}

void upd(int v, int tl, int tr, int l, int r, ll val) {
	if (l > r) {
		return;
	}

	if (tl == l && tr == r)  {
		t[v] += val;

		return;
	}

	push(v);
	int tm = (tl + tr) / 2;

	upd(v * 2, tl, tm, l, min(tm, r), val);
	upd(v * 2 + 1, tm + 1, tr, max(tm + 1, l), r, val);
}

ll get(int v, int tl, int tr, int pos) {
	if (tl == tr) {
		return t[v];
	}

	push(v);
	int tm = (tl + tr) / 2;
	if (pos <= tm) {
		return get(v * 2, tl, tm, pos);
	}
	else {
		return get(v * 2 + 1, tm + 1, tr, pos);
	}
}

vector<vi>g;
int tIn[N], tOut[N];
int tt = 0;

void dfs(int v, int p = -1) {
	tIn[v] = tt++;

	REP(i, sz(g[v])) {
		int u = g[v][i];
		if (u != p) {
			dfs(u, v);
		}
	}

	tOut[v] = tt++;
}

bool inner(int a, int b) {
	return tIn[b] <= tIn[a] && tOut[a] <= tOut[b];
}

int main(void) {
	int n;
	scanf("%d", &n);
	g.resize(n);
	CL(tIn, -1);
	CL(tOut, -1);
	vii edges;
	REP(i, n - 1) {
		int x, y;
		scanf("%d%d", &x, &y);
		x--, y--;
		g[x].pb(y);
		g[y].pb(x);
		edges.pb(mp(x, y));
	}

	dfs(0);

	int q;
	scanf("%d", &q);
	REP(i, q) {
		int type, e;
		ll x;
		scanf("%d%d%lld", &type, &e, &x);
		e--;
		if (type == 1) {
			if (inner(edges[e].X, edges[e].Y)) {
				upd(1, 0, n * 2 - 1, tIn[edges[e].X], tOut[edges[e].X], x);
			}
			else {
				upd(1, 0, n * 2 - 1, 0, n * 2 - 1, x);
				upd(1, 0, n * 2 - 1, tIn[edges[e].Y], tOut[edges[e].Y], -x);
			}
		}
		else {
			if (inner(edges[e].Y, edges[e].X)) {
				upd(1, 0, n * 2 - 1, tIn[edges[e].Y], tOut[edges[e].Y], x);
			}
			else {
				upd(1, 0, n * 2 - 1, 0, n * 2 - 1, x);
				upd(1, 0, n * 2 - 1, tIn[edges[e].X], tOut[edges[e].X], -x);
			}
		}
	}

	REP(i, n) {
		printf("%lld\n", get(1, 0, n * 2 - 1, tIn[i]));
	}

}

