#include <bits/stdc++.h>
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <class T>
istream &operator>>(istream &is, vector<T> &v) {
  for (long long i = 0; i < v.size(); i++) is >> v[i];
  return is;
}
template <class T>
ostream &operator<<(ostream &os, vector<T> v) {
  for (long long i = 0; i < v.size(); i++) os << v[i] << ' ';
  os << '\n';
  return os;
}
long long gcd(long long a, long long b) { return (a == 0) ? b : gcd(b % a, a); }
long long cnt_op(const string &s) {
  long long cur = 0;
  for (char c : s)
    if (c == '(')
      cur++;
    else {
      cur--;
      if (cur < 0) return -1;
    }
  return cur;
}
void reverse(string &s) {
  reverse(s.begin(), s.end());
  for (char &c : s)
    if (c == '(')
      c = ')';
    else
      c = '(';
}
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  long long n;
  cin >> n;
  vector<string> a(n);
  cin >> a;
  map<long long, long long> op;
  for (long long i = 0; i < n; i++) {
    long long t = cnt_op(a[i]);
    if (t == -1) {
      reverse(a[i]);
      t = cnt_op(a[i]);
      if (t >= 0) op[-t]++;
    } else
      op[t]++;
  }
  long long ans = 0;
  for (auto x : op)
    if (x.first <= 0) ans += x.second * op[-x.first];
  cout << ans;
}
