#include <bits/stdc++.h>
using namespace std;
struct DSU {
  vector<pair<int, pair<int, int>>> resParent;
  vector<pair<int, int>> resSize;
  vector<pair<int, int>> parent;
  vector<int> size;
  DSU(int n) {
    parent = vector<pair<int, int>>(n + 1);
    size = vector<int>(n + 1);
    for (int i = 1; i <= n; i++) {
      make_set(i);
    }
  }
  void make_set(int n) {
    parent[n] = {n, 0};
    size[n] = 1;
  }
  pair<int, int> find(int n) {
    if (parent[n].first != n) {
      pair<int, int> pa = find(parent[n].first);
      pa.second ^= parent[n].second;
      resParent.emplace_back(n, parent[n]);
      parent[n] = pa;
    }
    return parent[n];
  }
  bool make_union(int a, int b) {
    pair<int, int> pa = find(a);
    pair<int, int> pb = find(b);
    a = pa.first;
    b = pb.first;
    int p1 = pa.second;
    int p2 = pb.second;
    if (a == b && p1 == p2) {
      return true;
    }
    if (size[a] < size[b]) {
      swap(a, b);
    }
    size[a] += b;
    resParent.emplace_back(b, parent[b]);
    parent[b] = {a, p1 ^ p2 ^ 1};
    resSize.emplace_back(a, b);
    return false;
  }
};
void solve() {
  int n, m;
  long long k;
  scanf("%d %d %lld", &n, &m, &k);
  vector<bool> bi(n + 1);
  vector<int> vals(n + 1);
  map<pair<int, int>, vector<pair<int, int>>> map;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &vals[i]);
  }
  int a, b;
  DSU dsu(n);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &a, &b);
    if (vals[a] != vals[b]) {
      map[{min(vals[a], vals[b]), max(vals[a], vals[b])}].push_back({a, b});
      continue;
    }
    if (dsu.make_union(a, b) && !bi[vals[a]]) {
      bi[vals[a]] = true;
      k--;
    }
  }
  long long ans = 1LL * (k * (k - 1)) / 2;
  for (auto& test : map) {
    if (bi[test.first.first] || bi[test.first.second]) {
      continue;
    }
    int rp = dsu.resParent.size();
    int rs = dsu.resSize.size();
    for (auto& arr : test.second) {
      if (dsu.make_union(arr.first, arr.second)) {
        ans--;
        break;
      }
    }
    while (dsu.resSize.size() != rs) {
      dsu.size[dsu.resSize.back().first] -= dsu.size[dsu.resSize.back().second];
      dsu.resSize.pop_back();
    }
    while (dsu.resParent.size() != rp) {
      dsu.parent[dsu.resParent.back().first] = dsu.resParent.back().second;
      dsu.resParent.pop_back();
    }
  }
  printf("%lld\n", ans);
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
}
