#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast", "inline")
using namespace std;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const long long maxn = (long long)1e6 + 5;
const long long mod = 998244353;
const long long inf = 0x3f3f3f3f;
long long T = 1;
struct edge {
  long long u, v, colu, colv;
  bool operator<(const edge &b) const {
    if (colu != b.colu) return colu < b.colu;
    return colv < b.colv;
  };
} v[maxn];
long long tot = 0;
struct node {
  long long u, v, fa, siz;
};
stack<node> s;
long long pre[maxn];
long long find(long long x) {
  while (x != pre[x]) x = pre[x];
  return pre[x];
}
long long siz[maxn];
void unite(long long u, long long v) {
  u = find(u), v = find(v);
  if (siz[u] > siz[v]) swap(u, v);
  s.push({u, v, pre[u], siz[u]});
  if (u != v) {
    pre[u] = v;
    siz[v] += siz[u];
    siz[u] = 0;
  }
}
void restore() {
  node now = s.top();
  s.pop();
  if (now.u != now.v) {
    pre[now.u] = now.fa;
    siz[now.u] = now.siz;
    siz[now.v] -= now.siz;
  }
}
long long col[maxn];
bool no[maxn];
void solve() {
  long long n, m, k;
  cin >> n >> m >> k;
  long long cnt = k;
  for (long long i = 1; i <= n; ++i) cin >> col[i];
  for (long long i = 1; i <= 2 * n; ++i) pre[i] = i, siz[i] = 1;
  for (long long i = 1; i <= m; ++i) {
    long long x, y;
    cin >> x >> y;
    if (col[x] != col[y]) {
      v[++tot] = edge({x, y, col[x], col[y]});
      if (col[x] > col[y]) swap(v[tot].colu, v[tot].colv);
      continue;
    }
    if (no[col[x]]) continue;
    if (find(x) == find(y)) {
      --cnt;
      no[col[x]] = true;
      continue;
    }
    unite(x, y + n);
    unite(y, x + n);
  }
  long long ans = (cnt - 1) * cnt / 2;
  bool flag = false;
  sort(v + 1, v + tot + 1);
  long long last = s.size();
  for (long long i = 1; i <= tot; ++i) {
    edge now = v[i];
    if (no[now.colu] || no[now.colv]) continue;
    if (now.colu != v[i - 1].colu || now.colv != v[i - 1].colv) {
      while (s.size() != last) restore();
      flag = false;
    }
    if (flag) continue;
    if (find(now.u) == find(now.v)) {
      --ans;
      flag = true;
      continue;
    }
    unite(now.u, now.v + n);
    unite(now.v, now.u + n);
  }
  cout << ans;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  while (T--) solve();
  return 0;
}
