This problem is a programming version of Problem 61 from projecteuler.net
Triangle, square, pentagonal, hexagonal, heptagonal, and octagonal numbers are all figurate (polygonal) numbers and are generated by the following formulae:
The ordered set of three 4-digit numbers: 8128, 2882, 8281, has three interesting properties.
The set is cyclic, in that the last two digits of each number is the first two digits of the next number (including the last number with the first).
Each polygonal type: triangle , square , and pentagonal , is represented by a different number in the set.
This is the only set of 4-digit numbers with this property.
You are given a set of numbers find the sum of numbers from sets that respect the above property. If there are multiple such numbers print their sums in sorted order.
First line of input contains a number T.
Second line contains set of numbers each separated by a space.
Print the answer corresponding to the test case.
3 4 5