#include <bits/stdc++.h>
using namespace std;
[[gnu::constructor]] void fast_iostream() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cerr.tie(nullptr);
}
int main() {
  int n, k;
  cin >> n;
  vector<int> a(n);
  vector<int> dp(300300, 0), dm(300300, 0);
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    int need_p = 0, need_m = 0;
    for (int j = 0; j < ((int)(s).size()); ++j) {
      if (s[j] == '(') need_p++;
      if (need_p && s[j] == ')') need_p--;
    }
    for (int j = ((int)(s).size()) - 1; j >= 0; --j) {
      if (s[j] == ')') need_m++;
      if (need_m && s[j] == '(') need_m--;
    }
    if (need_p && need_m)
      a[i] = 1234567890;
    else
      a[i] = need_p - need_m;
  }
  for (int i = 0; i < n; ++i) {
    if (a[i] == 1234567890) continue;
    if (a[i] >= 0) dp[a[i]]++;
    if (a[i] <= 0) dm[abs(a[i])]++;
  }
  long long ans = 0;
  for (int i = 0; i < ((int)(dp).size()); ++i) ans += 1LL * dp[i] * dm[i];
  cout << ans << endl;
  return 0;
}
