Distributed Averaging and Balancing in Network Systems