#include #define rep(i,n) for(int i=0;i P; const ll INF = 1e18; const int MOD = 1000000007; int main(){ int n,m; cin >> n >> m; vector a(n); vector weight(n); vector cen(n); rep(i,n) cin >> a[i]; ll sum_weight = 0; rep(i,m){ ll x,w; cin >> x >> w; --x; cen[x] ++; weight[0] += abs(x); sum_weight += w; } ll cnt = cen[0]; for(int i=1;i