#include <bits/stdc++.h>
using namespace std;
stack<char> st;
long long int hl[1000000] = {0};
long long int hr[1000000] = {0};
long long int hb = 0;
void getIt(string s) {
  int l = 0, r = 0;
  for (char c : s) {
    if (c == '(')
      r++;
    else {
      if (r > 0)
        r--;
      else
        l++;
    }
  }
  if (l == 0 && r == 0)
    hb++;
  else if (l == 0)
    hr[r]++;
  else if (r == 0)
    hl[l]++;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<string> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int bc = 0, lc = 0, rc = 0;
  for (int i = 0; i < n; i++) {
    string s = a[i];
    getIt(s);
  }
  long long int ans = 0;
  for (int i = 0; i < 1000000; i++) {
    ans += (hl[i] * hr[i]);
  }
  ans += (hb * hb);
  cout << ans << '\n';
  return 0;
}
