# function to find sum of all of the nodes of given perfect binary tree
import math
def sumOfNodes(levl):
# no of leaf nodes
countOfLeafNodes = math.pow(2, levl - 1);
lastLevelSum = 0;
# sum of nodes at last level
sumAtLastLevel = ((countOfLeafNodes *
(countOfLeafNodes + 1)) / 2);
# sum of all nodes
sum = sumAtLastLevel * levl;
return int(sum);
# Driver Code
levl= 4;
print (sumOfNodes(levl));

## Comments