You don't even need to use Run For Each Item assertion if the following conditions hold:
1. The array will never be empty (or it is OK in this case to emit a single empty element)
2. The items in the array will never contain XML metacharacters (such as < > &) that require escaping
Then you can just use the join syntax built into the Gateway's string interpolation feature, where you can include a vertical bar after the variable name followed by a custom delimiter to use for joining multivalued variable items when interpolating into a string. You can change the template response to the following and delete the Run For Each Item assertion:
<names>
<name>${array|</name><name>}</name>
</names>
I've attached an edited sample policy showing this.