Given the following Python function, use optimization techniques to reduce the running time of the function.
def functionA(n):
 s = 0
 for i in range(n):
 for j in range(i+1):
 s += j
 return s
def functionA_opt(n):
 s = 0
 s = n*(n+1)*(n+2) // 6
 return s