#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5, M = 1e6, P = 1e9 + 7, INF = 0X3F3F3F3F;
const unsigned long long D = 743, mo = 966335533, mo1 = 966331133;
int n, m, k, a[N], b[N], c[N];
int id, z, top, fa[N], rk[N], ok[N];
pair<int, int> s[N];
map<pair<int, int>, int> Map;
std::vector<int> g[N];
int find(int x) { return x == fa[x] ? x : find(fa[x]); }
void merge(int u, int v) {
  int x = find(u), y = find(v);
  if (x != y) {
    if (rk[x] > rk[y]) swap(x, y);
    s[++top] = make_pair(x, rk[x] == rk[y]);
    fa[x] = y, rk[y] += (rk[x] == rk[y]);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
  }
  for (int i = 1; i <= m; i++) {
    cin >> a[i] >> b[i];
  }
  fill(ok + 1, ok + 1 + k, 1);
  for (int i = 1; i <= 2 * n; i++) fa[i] = i, rk[i] = 1;
  for (int i = 1, x, y; i <= m; i++) {
    if (c[a[i]] != c[b[i]]) continue;
    x = find(a[i]), y = find(b[i]);
    if (x == y) {
      ok[c[a[i]]] = 0;
    } else {
      merge(a[i], b[i] + n), merge(b[i], a[i] + n);
    }
  }
  for (int i = 1, x, y; i <= m; i++) {
    if (c[a[i]] == c[b[i]] || !ok[c[a[i]]] || !ok[c[b[i]]]) continue;
    x = c[a[i]], y = c[b[i]];
    if (x > y) swap(x, y);
    if (Map.count(make_pair(x, y))) {
      z = Map[make_pair(x, y)];
    } else {
      z = Map[make_pair(x, y)] = ++id;
    }
    g[z].push_back(i);
  }
  int nowTop, x, y;
  long long ans = 0, res = 0;
  for (auto it : Map) {
    nowTop = top;
    for (auto i : g[it.second]) {
      x = find(a[i]), y = find(b[i]);
      if (x == y) {
        --ans;
        break;
      } else {
        merge(a[i], b[i] + n), merge(b[i], a[i] + n);
      }
    }
    while (top > nowTop)
      rk[fa[s[top].first]] -= s[top].second, fa[s[top].first] = s[top].first,
                                             --top;
  }
  for (int i = 1; i <= k; i++)
    if (ok[i]) res++;
  cout << res * (res - 1) / 2 + ans << '\n';
  return 0;
}
