#include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i,n) for (int i=0; i<(int)(n); i++) using namespace std; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } typedef long long ll; typedef pair P; using Graph = vector>; //#define INF 10000000 class UnionFind{ public: vector par; UnionFind(int n) : par(n){ for(int i=0; i> n >> m; vector a(n); rep(i,n) cin >> a[i]; vector sum(n+1); for(int i=0; i