Order as per top occurences

Hi I have a file with entries like below

top 5
a 5
b 4
c 3
d 2
e 1
top 5
b 5 
d 4
c 3
e 2
a 1
top 5
e 5
d 4
c 3
b 2
a 1
top 5
a 5
c 4
d 3
b 2
e 1
top 5
a 5
e 4
b 3 
d 2
c 1

Now I want to get a output like

a 17
b 16
c 14
d 15
e 13

ie sum of the number mentioned in the same line. Above is a sample only I will create according to my need. Please help me on creating a script on the above example

Thanks,
Viswa

What have you tried so far and where exactly are you stuck?

Not only that.. Will there be a to e as first column?