Got accepted now by DP. Then I read posts in this thread. Some people misunderstood problem description. There is no need in sorting. If input is not sorted we should print that it is not A-sequence. Else check for sums.

A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman