import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable long MOD = 10^^9+7;

void main() {
    auto N = readln.chomp.to!int;
    auto S = N.iota.map!(_ => readln.chomp).array;
    auto cnts = new int[](N);
    auto mns = new int[](N);
    int[int] mn;


    foreach (i, s; S.enumerate) {
        int cnt = 0;
        int minv = 0;
        foreach (c; s) {
            cnt += c == '(' ? 1 : -1;
            minv = min(minv, cnt);
        }
        cnts[i] = cnt;
        mns[i] = minv;
        if (minv == cnts[i]) mn[minv] += 1;
    }

    long ans = 0;
    foreach (i; 0..N) {
        if (mns[i] < 0) continue;
        if (-cnts[i] !in mn) continue;
        ans += mn[-cnts[i]];
    }

    ans.writeln;
}
