#include <bits/stdc++.h>
using namespace std;
long long int d[505][505], d1[505][505], opt[505][505], opt1[505][505];
long long int a[505];
struct data {
  int s, f;
  long long int c;
  data(int __s = 0, int __f = 0, long long int __c = 0) {
    s = __s;
    f = __f;
    c = __c;
  }
};
vector<data> trucks[505];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  for (int i = 0; i <= 500; i++) {
    for (int j = 0; j <= 500; j++) {
      d[i][j] = 1e18 + 10;
    }
  }
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= m; i++) {
    int s, f, r;
    long long int c;
    cin >> s >> f >> c >> r;
    trucks[min(r + 1, n)].push_back(data(s, f, c));
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i; j++) d[i][j] = 0;
  }
  long long int res = 0;
  for (int K = 1; K <= n; K++) {
    for (int l = 1; l <= n; l++) {
      for (int r = l; r <= n; r++) {
        d1[l][r] = d[l][r];
        d[l][r] = 1e18 + 10;
      }
    }
    for (int l = 1; l <= n; l++) {
      int opt = l;
      for (int r = l; r <= n; r++) {
        while (opt <= r && max(d1[l][opt], a[r] - a[opt]) < d[l][r]) {
          d[l][r] = max(d1[l][opt], a[r] - a[opt]);
          opt++;
        }
        opt--;
      }
    }
    for (auto i : trucks[K]) {
      res = max(res, i.c * 1ll * d[i.s][i.f]);
    }
  }
  cout << res << endl;
  return 0;
}
