#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N;
  cin >> N;
  string s[N];
  long long int a, b, c, i, j, k, ans = 0;
  map<long long int, long long int> m;
  map<long long int, long long int> m1;
  map<long long int, long long int> m2;
  c = 0;
  for (i = 0; i < N; i++) {
    cin >> s[i];
    a = 0;
    for (j = 0; j < s[i].length(); j++) {
      if (s[i].at(j) == '(')
        a++;
      else
        a--;
    }
    if (a == 0) {
      if ((s[i].at(0) != ')') && (s[i].at(s[i].length() - 1) != '(')) {
        k = 0;
        b = 0;
        for (j = 0; j < s[i].length(); j++) {
          if (s[i].at(j) == '(')
            b++;
          else
            k++;
          if (k > b) break;
        }
        if (j == s[i].length()) {
          ans++;
          ans += 2 * c;
          c++;
        }
      }
    } else if (a < 0) {
      k = 0;
      b = 0;
      for (j = 0; j < s[i].length(); j++) {
        if (s[i].at(j) == '(')
          b++;
        else {
          if (b > 0) b--;
        }
      }
      if (b == 0) {
        m1[a]++;
      }
    } else {
      k = 0;
      b = 0;
      for (j = 0; j < s[i].length(); j++) {
        if (s[i].at(j) == '(')
          b++;
        else
          k++;
        if (k > b) break;
      }
      if (j == s[i].length()) {
        m[a]++;
      }
    }
  }
  auto x = m.begin();
  while (x != m.end()) {
    a = x->first;
    b = x->second;
    a = a * -1;
    ans += b * m1[a];
    x++;
  }
  cout << ans << "\n";
  return 0;
}
