#include <bits/stdc++.h>
using namespace std;
const long long inf = 4e18;
const long long maxn = 2e5 + 10;
const long long mod = 1e9 + 7;
#pragma GCC Optimize("Ofast")
map<long long, long long> pos, neg;
long long zero;
int main() {
  long long n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    long long num = 0, mn = 0;
    for (int j = 0; j < (s).size(); j++) {
      num += ((s[j] == '(') ? (1) : (-1));
      mn = min(mn, num);
    }
    if (num == 0 && mn == 0) zero++;
    if (num < 0 && mn == num) neg[num]++;
    if (num > 0 && mn >= 0) pos[num]++;
  }
  long long ans = (zero * zero);
  for (map<long long, long long>::iterator it = pos.begin(); it != pos.end();
       it++) {
    ans += pos[(it->first)] * neg[-(it->first)];
  }
  cout << ans;
}
