#include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
const int MAX_N = 3 * 1e5 + 1;
const long long INF = 1e9;
const long long delta = 10957;
using namespace std;
bool check(string s) {
  long long sum = 0;
  for (int i = 0; i < s.length(); ++i) {
    if (sum < 0) return false;
    if (s[i] == ')')
      sum--;
    else
      sum++;
  }
  if (!sum) return true;
  return false;
}
string filter(string s) {
  long long pos = s.find("()");
  while (pos != s.npos) {
    s.erase(pos, 2);
    pos = s.find("()");
  }
  if (s[0] != s[s.length() - 1]) return "";
  return s;
}
long long counter1[MAX_N];
long long counter2[MAX_N];
int main() {
  ios::sync_with_stdio(false);
  cout.tie();
  cin.tie();
  int n;
  cin >> n;
  long long cnt = 0;
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    bool f = check(s);
    if (f) {
      cnt++;
      continue;
    }
    if (!f) s = filter(s);
    if (s != "") {
      if (s[0] == ')')
        counter2[s.length()]++;
      else
        counter1[s.length()]++;
    }
  }
  ans = cnt * cnt;
  for (int i = 1; i < MAX_N; ++i) ans += counter1[i] * counter2[i];
  cout << ans;
  return 0;
}
