#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const long long MOD = (int)1e9 + 7;
const long long MOR = (int)1e9 + 31;
const long long INF = (long long)1e9 + 100;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int MAXN = (int)2e5 + 5;
const double pi = 3.14159265358979323846;
const int SZ = 1;
long long n, m, a[MAXN], k, pr[100], cnt, b, c;
string s, t;
map<pair<long long, long long>, long long> cn;
pair<long long, long long> f(string &s) {
  long long le = 0, ri = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '(') le++;
    if (s[i] == ')') {
      if (le > 0)
        le--;
      else
        ri++;
    }
  }
  return make_pair(le, ri);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    cn[f(s)]++;
  }
  for (auto p : cn) {
    pair<long long, long long> c = p.first;
    long long val = p.second;
    if (c.first != 0 && c.second != 0) continue;
    if (c.first == 0 && c.second == 0) {
      cnt += val * val;
      continue;
    }
    if (c.first != 0) cnt += val * cn[make_pair(c.second, c.first)];
  }
  cout << cnt;
}
