#include <bits/stdc++.h>
using namespace std;
const int maxn = 305000;
map<int, int> pl;
map<int, int> pr;
int ls[maxn], rs[maxn], vis[maxn];
long long ck, ans1, ans2, n;
string tmp;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    int cnt1 = 0, cnt2 = 0;
    for (int j = 0, d = tmp.size(); j < d; j++) {
      if (tmp[j] == '(')
        cnt1++;
      else {
        if (cnt1 > 0)
          cnt1--;
        else
          cnt2++;
      }
    }
    if (cnt1 > 0 && cnt2 > 0) {
      vis[i] = -1;
      continue;
    }
    if (cnt1 == 0 && cnt2 == 0) {
      vis[i] = 2;
      ck++;
    }
    if (cnt1 > 0) {
      pl[cnt1]++;
      ls[i] = cnt1;
    }
    if (cnt2 > 0) {
      pr[cnt2]++;
      rs[i] = cnt2;
    }
  }
  for (int i = 0; i < n; i++) {
    if (vis[i] == -1) continue;
    if (vis[i] == 2) {
      ans1 += ck;
      continue;
    }
    if (ls[i] > 0) ans2 += pr[ls[i]];
    if (rs[i] > 0) ans2 += pl[rs[i]];
  }
  cout << ans1 + ans2 / 2 << endl;
  return 0;
}
