#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  char ch = getchar();
  long long f = 1;
  while (!isdigit(ch)) {
    if (ch == '-') f *= -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  x *= f;
}
template <typename T, typename... Args>
void read(T &first, Args &...args) {
  read(first);
  read(args...);
}
template <typename T>
void write(T arg) {
  T x = arg;
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) {
    write(x / 10);
  }
  putchar(x % 10 + '0');
}
template <typename T, typename... Ts>
void write(T arg, Ts... args) {
  write(arg);
  if (sizeof...(args) != 0) {
    putchar(' ');
    write(args...);
  }
}
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
const int N = 1000005;
map<pair<int, int>, int> ma;
vector<int> ve[N];
int n, m, k;
int c[N], a[N], b[N];
int f[N];
struct Undo_Dsu {
  stack<pair<int, int> > st;
  int fa[N], siz[N];
  void init() {
    while (!st.empty()) st.pop();
    for (int i = 1; i <= n * 2 + 1; i++) fa[i] = i, siz[i] = 1;
  }
  int findroot(int x) { return x == fa[x] ? x : findroot(fa[x]); }
  bool merge(int u, int v) {
    int fax = findroot(u), fay = findroot(v);
    if (fax == fay) return false;
    if (siz[fax] > siz[fay]) swap(fax, fay), swap(u, v);
    fa[fax] = fay, siz[fay] += siz[fax];
    st.push({fax, fay});
    return true;
  }
  void undo() {
    pair<int, int> no = st.top();
    fa[no.first] = no.first;
    siz[no.second] -= siz[no.first];
    st.pop();
  }
} dsu;
int main() {
  long long ans = 0;
  read(n, m, k);
  dsu.init();
  for (int i = 1; i <= n; i++) read(c[i]);
  for (int i = 1; i <= m; i++) read(a[i], b[i]);
  for (int i = 1; i <= m; i++) {
    if (c[a[i]] == c[b[i]]) {
      int fau = dsu.findroot(a[i]);
      int fav = dsu.findroot(b[i]);
      if (fau == fav)
        f[c[a[i]]] = 1;
      else
        dsu.merge(a[i], b[i] + n), dsu.merge(b[i], a[i] + n);
    }
  }
  int type = 0;
  for (int i = 1; i <= m; i++) {
    if (c[a[i]] != c[b[i]] && !f[c[a[i]]] && !f[c[b[i]]]) {
      int lc = c[a[i]], rc = c[b[i]];
      if (lc > rc) swap(lc, rc);
      int id = ma[make_pair(lc, rc)];
      if (!id) id = ma[make_pair(lc, rc)] = ++type;
      ve[id].push_back(i);
    }
  }
  for (auto x : ma) {
    int w = x.second;
    int now = (int)dsu.st.size();
    for (auto vv : ve[w]) {
      int uid = a[vv], vid = b[vv];
      int fau = dsu.findroot(uid), fav = dsu.findroot(vid);
      if (fau == fav) {
        --ans;
        break;
      }
      dsu.merge(uid, vid + n);
      dsu.merge(vid, uid + n);
    }
    while ((int)dsu.st.size() > now) dsu.undo();
  }
  int cnt = 0;
  for (int i = 1; i <= k; i++)
    if (!f[i]) cnt++;
  ans += 1ll * cnt * (cnt - 1) / 2;
  write(ans), putchar('\n');
}
