#include <bits/stdc++.h>
using namespace std;
const int N = 1010101;
const int LOGN = (int)log2(N) + 2;
int SQRTN = (int)sqrt(N) + 7;
const long long infi = 1ll << 60;
long long n, m, a, b, k, x, y, ans, arr[N];
map<long long, long long> mp;
string second;
void push_it() {
  int cur = 0;
  bool neg = false, pos = false;
  for (auto& c : second) {
    if (c == '(')
      ++cur;
    else
      --cur;
    if (cur > 0) pos = true;
    if (cur < 0) neg = true;
  }
  if (cur == 0) {
    if (neg) return;
    ++mp[cur];
    return;
  }
  if (cur > 0) {
    if (neg) return;
    ++mp[cur];
    return;
  }
  if (cur < 0) {
    pos = neg = false;
    cur = 0;
    for (int(i) = ((long long)second.size() - 1); (i) >= (0); --(i)) {
      if (second[i] == '(')
        ++cur;
      else
        --cur;
      if (cur > 0) pos = true;
      if (cur < 0) neg = true;
    }
    if (pos) return;
    ++mp[cur];
    return;
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  cin >> n;
  for (int(i) = (1); (i) <= (int)(n); ++(i)) {
    cin >> second;
    push_it();
  }
  for (auto& cur : mp) {
    if (cur.first > 0) break;
    if (cur.first == 0) {
      ans += cur.second * cur.second;
      break;
    } else {
      ans += cur.second * mp[-cur.first];
    }
  }
  cout << ans << endl;
  return 0;
}
