Chemistry-Inspired Algorithm for Emergent Distributed Consensus in WSNs