#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T gcd(T a, T b) {
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
string process(string &item) {
  stack<char> chars;
  for (int i = 0; i < (int)item.size(); i++) {
    if (chars.size() == 0) {
      chars.push(item[i]);
    } else {
      char top = chars.top();
      if (top == '(' && item[i] == ')') {
        chars.pop();
      } else {
        chars.push(item[i]);
      }
    }
  }
  string it;
  while (!chars.empty()) {
    char top = chars.top();
    chars.pop();
    it.push_back(top);
  }
  reverse(it.begin(), it.end());
  return it;
}
string rev(string item) {
  string rv;
  for (int i = 0; i < (int)item.size(); i++) {
    if (item[i] == '(') {
      rv.push_back(')');
    } else {
      rv.push_back('(');
    }
  }
  return rv;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  map<string, long long> items;
  for (int i = 1; i <= n; i++) {
    string item;
    cin >> item;
    string res = process(item);
    items[res]++;
  }
  long long sum = 0;
  sum = items[""] * items[""];
  items.erase("");
  for (auto ttt : items) {
    bool found = true;
    for (int i = 0; i < ttt.first.size(); i++) {
      if (ttt.first[i] == ')') {
        found = false;
        break;
      }
    }
    if (!found) continue;
    string r = rev(ttt.first);
    if (items.count(r) > 0) {
      sum += ttt.second * items[r];
    }
  }
  cout << sum << endl;
  return 0;
}
