#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int maxn = 3e5 + 5;
vector<string> a;
int cnt, cntl[maxn], cntr[maxn];
string check(string s) {
  stack<char> m;
  for (int i = 0; i < s.length(); i++) {
    if (m.empty()) {
      m.push(s[i]);
      continue;
    }
    char c = m.top();
    if (c == '(' && s[i] == ')')
      m.pop();
    else
      m.push(s[i]);
  }
  string t;
  while (!m.empty()) {
    t += m.top();
    m.pop();
  }
  reverse(t.begin(), t.end());
  return t;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  memset((cntl), 0, sizeof(cntl));
  memset((cntr), 0, sizeof(cntr));
  a.clear();
  cnt = 0;
  a.push_back(" ");
  int n;
  string s;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    a.push_back(check(s));
  }
  for (int i = 1; i <= n; i++) {
    int len = a[i].length();
    if (len == 0)
      cnt++;
    else if (a[i][0] == '(' && a[i][len - 1] == '(')
      cntl[len]++;
    else if (a[i][0] == ')' && a[i][len - 1] == ')')
      cntr[len]++;
  }
  long long ans = 1LL * cnt * cnt;
  for (int i = 1; i <= 300000; i++) ans += 1LL * cntl[i] * cntr[i];
  cout << ans << endl;
  return 0;
}
