#include #include using namespace std; using namespace atcoder; using ll=long long; using mint=modint998244353; int main() { int n; cin>>n; vector a(n); for(int i=0;i>a[i]; vector> graph(n); for(int i=1;i>u>>v; u--;v--; graph[u].push_back(v); graph[v].push_back(u); } mint ans=0; auto dfs=[&](auto dfs,int v,int par)->mint{ mint res=a[v],t=0; for(int u:graph[v]){ if(u==par)continue; t=dfs(dfs,u,v); ans+=res*t; res+=t*a[v]; } return res; }; dfs(dfs,0,-1); cout<