Instead of storing node values, store cumulative sums. When entering node , add its value. When exiting, subtract its value. Now arr[tin[v]] holds +value[v] and arr[tout[v]] holds -value[v].
Path sum from root to = prefix sum from to tin[v] in this array. This works because DFS enters all ancestors before and exits them after, so their contributions are counted exactly once.