ループ回数はnじゃないの?
for(i=0; i<n; i++) {
s += x[i];
ss += x[i] * x[i];
}
a = s / n;
ss -= a * s;
sigma2 = ss / n;