#include <bits/stdc++.h>
using namespace std;
int N;
char str[100];
int main() {
  scanf("%d%s", &N, str);
  int lucky = 1, suml = 0, sumr = 0;
  for (int i = 0; i < N; i++) {
    if (str[i] != '4' && str[i] != '7') lucky = 0;
    if (i < N / 2) suml += str[i] - '0';
    if (i >= N / 2) sumr += str[i] - '0';
  }
  lucky &= (suml == sumr);
  if (lucky)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
