// Cheese-Cracker: cheese-cracker.github.io

void theCode(){
    int n;
    n = scan!int;
    auto arr = scanArray;
    auto freq = new ll[1000];
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < i; ++j){
            ++freq[to!int(abs(arr[j] - arr[i]))];
        }
    }
    ll cnt = 0;
    for(int i = 0; i < 1000; ++i){
        if(freq[i]){
            ++cnt;
        }
    }
    writeln(cnt);
}

void main(){
    long tests = 1;
    tests = scan;        // Toggle!
    while(tests--) theCode();
}

/*********  That's All Folks!  *********/
import std.stdio, std.conv, std.functional, std.string, std.algorithm;
import std.container, std.range, std.typecons, std.numeric, std.math, std.random;
static string[] tk;
T scan(T=long)(){while(!tk.length)tk = readln.split; string a=tk.front; tk.popFront; return a.to!T;}
T[] scanArray(T=long)(){ auto r = readln.split.to!(T[]); return r; }
void show(A...)(A a){ debug{ foreach(t; a){stderr.write(t, "| ");} stderr.writeln; } }
alias ll = long, tup = Tuple!(long, "x",  long, "y");
