#include <bits/stdc++.h>
using namespace std;
vector<long long int> colors;
vector<pair<long long int, long long int>> resS;
vector<pair<pair<long long int, long long int>, long long int>> resP;
map<pair<long long int, long long int>,
    vector<pair<long long int, long long int>>>
    mapa;
struct DSU {
  vector<long long int> size;
  vector<pair<long long int, long long int>> parent;
  DSU(long long int n) {
    size = vector<long long int>(n);
    parent = vector<pair<long long int, long long int>>(n);
    for (long long int i = 0; i < n; i++) {
      parent[i] = make_pair(i, 0);
    }
  }
  pair<long long int, long long int> find(long long int pos) {
    if (parent[pos].first != pos) {
      pair<long long int, long long int> par = find(parent[pos].first);
      resP.emplace_back(parent[pos], pos);
      par.second ^= parent[pos].second;
      parent[pos] = par;
    }
    return parent[pos];
  }
  bool unionSet(long long int a, long long int b) {
    pair<long long int, long long int> ap = find(a);
    pair<long long int, long long int> bp = find(b);
    a = ap.first;
    b = bp.first;
    if (a == b) {
      return ap.second != bp.second;
    }
    if (size[a] < size[b]) {
      swap(a, b);
      swap(ap, bp);
    }
    resS.emplace_back(a, size[a]);
    resP.emplace_back(parent[b], b);
    parent[b] = ap;
    parent[b].second = 1 ^ ap.second ^ bp.second;
    size[a] += size[b];
    return true;
  }
};
void solve() {
  long long int n, m, k, a1, a2, ans;
  set<long long int> cant;
  cin >> n >> m >> k;
  DSU dsu(n);
  colors = vector<long long int>(n);
  for (long long int i = 0; i < n; i++) {
    cin >> colors[i];
  }
  for (long long int i = 0; i < m; i++) {
    cin >> a1 >> a2;
    a1--;
    a2--;
    if (cant.count(colors[a1]) || cant.count(colors[a2])) {
      continue;
    }
    if (colors[a1] > colors[a2]) {
      swap(a1, a2);
    }
    if (colors[a1] == colors[a2]) {
      if (!dsu.unionSet(a1, a2)) {
        cant.insert(colors[a1]);
        k--;
      }
    } else {
      mapa[make_pair(colors[a1], colors[a2])].emplace_back(a1, a2);
    }
  }
  ans = (k * (k - 1)) / 2;
  for (auto& p : mapa) {
    long long int sizeS = resS.size();
    long long int sizeP = resP.size();
    if (cant.count(p.first.first) || cant.count(p.first.second)) {
      continue;
    }
    for (auto& con : p.second) {
      if (!dsu.unionSet(con.first, con.second)) {
        ans--;
        break;
      }
    }
    while ((long long int)resS.size() != sizeS) {
      auto cur = resS.back();
      dsu.size[cur.first] = cur.second;
      resS.pop_back();
    }
    while ((long long int)resP.size() != sizeP) {
      auto cur = resP.back();
      dsu.parent[cur.second] = cur.first;
      resP.pop_back();
    }
  }
  cout << ans << endl;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
}
