Strings and suffix

How can we find the sum of sizes of common prefix that a suffix of length r has with all suffices of length greater than r? We have to find this answer for all r. I tried this using suffix trees and got an O(n^2) algorithm where n is the length of the string. The main problem I could not handle was the restriction that only suffice of length greater than r were to be considered.