#include <bits/stdc++.h>
using namespace std;
const int maxn = 500000 + 9;
int fa[maxn * 2], c[maxn], good[maxn];
int n, m, k;
vector<pair<int*, int>> S;
int ffa(int x, bool se = 0) {
  if (fa[x] == x) return x;
  int z = ffa(fa[x], se);
  if (se) S.emplace_back(&fa[x], fa[x]);
  return fa[x] = z;
}
void merge(int x, int y, bool se = 0) {
  x = ffa(x, se);
  y = ffa(y, se);
  if (x != y) {
    if (x < y) swap(x, y);
    if (se) S.emplace_back(&fa[x], fa[x]);
    fa[x] = y;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  cin >> n >> m >> k;
  for (int i = 0; i < n; ++i) cin >> c[i];
  for (int i = 1; i <= k; ++i) good[i] = 1;
  for (int i = 0; i < 2 * n; ++i) fa[i] = i;
  vector<pair<int, int>> edges;
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    --u;
    --v;
    if (c[u] == c[v]) {
      merge(u, v + n);
      merge(v, u + n);
      if (ffa(u) == ffa(u + n)) {
        good[c[u]] = 0;
      }
    } else {
      if (c[u] > c[v]) swap(u, v);
      edges.emplace_back(u, v);
    }
  }
  m = edges.size();
  long long totc = count(good + 1, good + 1 + k, 1);
  long long ans = (totc - 1) * totc / 2;
  vector<int> idx(m);
  iota(idx.begin(), idx.end(), 0);
  sort(idx.begin(), idx.end(), [&](int i, int j) {
    return make_pair(c[edges[i].first], c[edges[i].second]) <
           make_pair(c[edges[j].first], c[edges[j].second]);
  });
  for (int i = 0; i < m;) {
    int j = i;
    while (i < m && c[edges[idx[i]].first] == c[edges[idx[j]].first] &&
           c[edges[idx[i]].second] == c[edges[idx[j]].second]) {
      ++i;
    }
    if (!good[c[edges[idx[j]].first]] || !good[c[edges[idx[j]].second]])
      continue;
    for (int x = j; x < i; ++x) {
      auto [u, v] = edges[idx[x]];
      merge(u, v + n, 1);
      merge(v, u + n, 1);
      if (ffa(u, 1) == ffa(u + n, 1)) {
        ans--;
        break;
      }
    }
    while (!S.empty()) {
      auto [p, q] = S.back();
      S.pop_back();
      *p = q;
    }
  }
  cout << ans << "\n";
  return 0;
}
