#include <bits/stdc++.h>
#define pq priority_queue
using namespace std; typedef pair<int, int> P; typedef pair<int, P> P2;
typedef pair<int, P2> P3; typedef long long ll; typedef long double ld;
constexpr long long gcd(long long a, long long b){return b ? gcd(b, a % b) : a;}
constexpr long long lcm(long long a, long long b){return a / gcd(a, b) * b;}
constexpr int INF = 1e9, MOD = INF + 7, around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0};
constexpr int mod_pow(long long x, long long n, const int mod){long long ret=1;while(n){if(n&1)(ret*=x)%=mod;(x*=x)%=mod;n>>=1;}return ret;}
template<int n> struct Prime{bool arr[n+1];constexpr bool operator[](int k){return arr[k];}constexpr Prime():arr(){for(int i=2;i<n;i++){arr[i]=true;for(int j=2;j*j<=i;j++){if(!(i%j))arr[i]=false;}}}};
template<int n> struct Factorial{long long arr[n+1],ary[n+1];constexpr Factorial():arr(),ary(){arr[0]=1;ary[0]=1;for(int i=0;i<n;i++){arr[i+1]=arr[i]*(i+1)%MOD;ary[i+1]=mod_pow(arr[i+1],MOD-2,MOD);}}};
constexpr Factorial<10> fact; constexpr Prime<10> prime;
constexpr int comb(int a, int b){long long pos = fact.arr[a], pot = fact.ary[a - b], por = fact.ary[b];return pos * pot % MOD * por % MOD;}
template<int n> struct Bernoulli{long long arr[n+1];constexpr Bernoulli():arr(){arr[0]=1;for(int i=1;i<=n;i++){long long sum=0;for(int j=0;j<i;j++){(sum+=comb(i+1,j)*arr[j]%MOD)%=MOD;}arr[i]=(MOD-mod_pow(i+1,MOD-2,MOD))%MOD*sum%MOD;}}};
constexpr int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
constexpr int sqrtN = 512, logN = 32;
constexpr ld PI = abs(acos(-1));
constexpr ll LINF=1e18;

ll s = 0;
int n, m, p[100010];
vector<vector<int>> g;

struct UnionFind{
	vector<int> data;
	
	UnionFind(int n){
		data.assign(n, -1);
	}
	
	void unite(int x, int y){
		x = find(x); y = find(y);
		if(x == y) return;
		if(data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
	}
	
	int find(int k){
		if(data[k] < 0) return k;
		return data[k] = find(data[k]);
	}
};

struct LowLink{
	UnionFind uf;
	vector<vector<int>> g, G;
	vector<int> used, ord, low, parent;
	vector<ll> dp;
	
	LowLink(const vector<vector<int>> g) : g(g), uf(g.size()){
		G.resize(g.size());
		used.assign(g.size(), false);
		ord.resize(g.size());
		low.resize(g.size());
		parent.assign(g.size(), -1);
		dp.resize(g.size());
	}

	int solve(int v){
		ll ret = 0;
		if(!v){
			if(G[v].size() >= 2) for(auto e:G[v]) ret = max(ret, dp[v]);
			else ret = s - p[v];
		}else{
			ll sum = s - dp[v], ma = 0; bool f = false;
			for(auto e:G[v]){
				if(ord[v] <= low[e]) ma = max(ma, dp[e]), f = true; 
				else sum += dp[e];
			}
			
			ret = max(ma, sum);
		}
		
		return ret;
	}

	void solve(){
		dfs();
		
		for(int i = 0; i < n; i++) cout << solve(i) << endl;
	}

	void dfs(int v, int &k, int par = -1){
		used[v] = true;
		ord[v] = k++;
		low[v] = ord[v];
		parent[v] = par;
		
		for(auto e:g[v]){
			if(!used[e]){
				dfs(e, k, v);
				G[v].push_back(e);
				low[v] = min(low[v], low[e]);
				if(ord[v] >= low[e]) uf.unite(v, e);
			}else if(e != par){
				low[v] = min(low[v], ord[e]);
			}
		}
	}
	
	int _dfs(int v, int par = -1){
		if(dp[v]) return dp[v];
		
		ll ret = p[v];
		for(auto e:G[v]){
			if(e == par) continue;
			ret += _dfs(e, v);
		}
		
		return dp[v] = ret;
	}

	void dfs(){
		int k = 0;
		dfs(0, k);
		_dfs(0);
	}
};

int main(){
	cin >> n >> m; g.resize(n);
	for(int i = 0; i < n; i++) cin >> p[i], s += p[i];
	for(int i = 0; i < m; i++){
		int a, b; cin >> a >> b;
		g[a - 1].push_back(b - 1);
		g[b - 1].push_back(a - 1);
	}
	LowLink low(g);
	low.solve();
	return 0;
}

//~ まず, 頂点を切っても連結の時は自明 -> よって関節点だけを考えればよい.

