// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract EqualDistribution {
    // Function to distribute the received ETH equally among the provided addresses
    function distributeETH(address[] memory _addresses) public payable {
        require(_addresses.length > 0, "No addresses provided");

        uint256 amount = msg.value / _addresses.length;
        require(amount > 0, "Insufficient ETH for distribution");

        for (uint i = 0; i < _addresses.length; i++) {
            payable(_addresses[i]).transfer(amount);
        }

        // Refund any remaining ETH to the sender (due to division remainder)
        uint256 remainder = msg.value - (amount * _addresses.length);
        if (remainder > 0) {
            payable(msg.sender).transfer(remainder);
        }
    }
    
    receive() payable external {}
}