def potential(r):
    return 4.0 * (r ** -12 - r ** -6)

def total_energy(x):
    E = 0.0
for i in range(N - 1):
    E += potential(np.sqrt((x[i] - x[:i]) ** 2)).sum()
return E
how to write this in most effecient way