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

int n,m,a[100005],x,y,sreca[100005],usreca;
vector<int> cv[100005];

int main() {

cin>>n>>m;

    for(int i=1;i<=n;i++){
        cin>>a[i];
    }

    for(int i=1;i<=m;i++){
        cin>>x>>y;
        cv[x].push_back(y);
        cv[y].push_back(x);

    }

    for(int i=1;i<=n;i++){
        sreca[i]=a[i]*cv[i].size();
        cout<<sreca[i]<<endl;
        usreca+=sreca[i];
    }
    cout<<usreca<<endl;

return 0;
}