#include <bits/stdc++.h>
using namespace std;
const int MX = 5e5 + 5;
int n, m, k;
int val[MX], col[MX], par[MX];
int tmpval[MX], tmppar[MX];
pair<int, int> edge[MX];
map<pair<int, int>, vector<int> > mp;
bool ban[MX];
int find(int nw) {
  if (par[nw] == nw) return nw;
  int gt = find(par[nw]);
  val[nw] ^= val[par[nw]];
  return par[nw] = gt;
}
int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    cin >> col[i];
    par[i] = i;
  }
  for (int i = 1; i <= m; i++) {
    cin >> edge[i].first >> edge[i].second;
    if (col[edge[i].first] == col[edge[i].second]) {
      if (find(edge[i].first) != find(edge[i].second)) {
        int p = find(edge[i].first), q = find(edge[i].second);
        val[p] = val[edge[i].first] ^ val[edge[i].second] ^ 1;
        par[p] = q;
      } else if (!ban[col[edge[i].first]] &&
                 val[edge[i].first] == val[edge[i].second]) {
        ban[col[edge[i].first]] = 1;
        k--;
      }
    } else
      mp[{min(col[edge[i].first], col[edge[i].second]),
          max(col[edge[i].first], col[edge[i].second])}]
          .push_back(i);
  }
  for (int i = 1; i <= n; i++) find(i);
  for (int i = 1; i <= n; i++) tmppar[i] = par[i], tmpval[i] = val[i];
  long long ans = k * 1ll * (k - 1) / 2ll;
  for (auto x : mp) {
    if (!ban[x.first.first] && !ban[x.first.second]) {
      ans--;
      int r = 1;
      vector<int> id;
      for (int i : x.second) {
        id.push_back(edge[i].first);
        id.push_back(edge[i].second);
        if (find(edge[i].first) != find(edge[i].second)) {
          id.push_back(find(edge[i].first));
          int p = find(edge[i].first), q = find(edge[i].second);
          val[p] = val[edge[i].first] ^ val[edge[i].second] ^ 1;
          par[p] = q;
        } else if (val[edge[i].first] == val[edge[i].second])
          r = 0;
      }
      ans += r;
      for (int i : id) {
        par[i] = tmppar[i];
        val[i] = tmpval[i];
      }
    }
  }
  cout << ans << endl;
  return 0;
}
