#include #include #include #include #define MAXN 2500000 #define max(a,b) ((a) > (b) ? (a) : (b)) int nw; long long weights[MAXN]; int cmp(const void *a1, const void *b1) { long long a = *((long long *) a1); long long b = *((long long *) b1); if ( ab ) return 1; return 0; } int read(int level) { char c = getc(stdin); long long w; if ( c=='[' ) { read(level+1); c = getc(stdin); if ( c!=',' ) return 0; read(level+1); c = getc(stdin); if ( c!=']' ) return 0; } else { ungetc(c,stdin); scanf("%lld",&w); weights[nw++] = w*(1<