#include <bits/stdc++.h>
using namespace std;
int getint() {
  unsigned int c;
  int x = 0;
  while (((c = getchar()) - '0') >= 10) {
    if (c == '-') return -getint();
    if (!~c) exit(0);
  }
  do {
    x = (x << 3) + (x << 1) + (c - '0');
  } while (((c = getchar()) - '0') < 10);
  return x;
}
int getc_str(char str[]) {
  unsigned int c, n = 0;
  while ((c = getchar()) <= ' ')
    ;
  if (!~c) exit(0);
  do {
    str[n++] = c;
  } while ((c = getchar()) > ' ');
  str[n] = '\0';
  return n;
}
char in[100];
int main() {
  int i, j, tcc, tc = 1 << 28;
  for (tcc = 0; tcc < tc; tcc++) {
    int n = getint();
    getc_str(in);
    bool ok = 1;
    for (i = 0; i < n; i++) {
      if (in[i] != '4' and in[i] != '7') ok = 0;
    }
    int firstSum = 0, secondSum = 0;
    for (i = 0; i < n / 2; i++) firstSum += in[i];
    for (i = 0; i < n / 2; i++) secondSum += in[i + n / 2];
    if (firstSum != secondSum) ok = 0;
    if (ok) {
      puts("YES");
    } else {
      puts("NO");
    }
  }
  return 0;
}
