Given an array of integers, write an algorithm to partition the array into three parts such that the sum of elements in each part is equal.