Balloon Burst Problem

There are n balloons and n bullets and each balloon is assigned with a particular number (point). Whenever a particular balloon is shot the no of points increases by 1.the multiplication of point assigned to balloon on left and that of right side.

2.point assigned to left if no right exists

3.point assigned to right if no left exists.

4.the point assigned to itself if no other balloon exists.

You have to output the maximum no of points possible.

Input

1 2 3 4

Output

20

Can you explain me the solution?
Here it is :

@tasfikrahman007 hey bro check this video of explanation you will get it: