#include <bits/stdc++.h>
using namespace std;
long long m, n, x, y, z, p, q, r;
char str[400000];
long long frstjoggo[400000], scndjoggo[400000], uvoyjoggo[400000];
pair<long long, long long> ara[400000];
long long ans;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%s", str);
    long long len = strlen(str);
    long long khrpfr = 0, khrpsc = 0;
    stack<char> st;
    for (long long j = 0; j < len; j++) {
      if (str[j] == '(')
        st.push(str[j]);
      else {
        if (st.empty())
          khrpsc++;
        else
          st.pop();
      }
    }
    khrpfr = st.size();
    if (khrpfr == 0) scndjoggo[khrpsc]++;
    if (khrpsc == 0) frstjoggo[khrpfr]++;
    if (khrpfr == 0 && khrpsc == 0) uvoyjoggo[khrpfr]++;
    ara[i] = {khrpfr, khrpsc};
  }
  long long sobvalo = 0;
  for (long long i = 1; i <= n; i++) {
    if (ara[i].first == 0 && ara[i].second == 0) {
      sobvalo++;
      continue;
    }
    if (ara[i].first == 0) {
      ans += frstjoggo[ara[i].second];
    }
    if (ara[i].second == 0) {
      ans += scndjoggo[ara[i].first];
    }
  }
  cout << ans / 2 + sobvalo * sobvalo << endl;
  return 0;
}
