def Trid(x):
    """Trid(n == 6) = -50, Trid(n = 10) = -200"""
    n = len(x)
    s1 = 0
    s2 = 0
    for ii in range(n):
        s1 += pow(x[ii] - 1, 2.0)
    for ii in range(1, n):
        s2 += x[ii] * x[ii - 1]
    return s1 - s2
